I accidentally turned LLM memory into program analysis
TL;DR Highlight
Keeping LLM memory as Datalog rules beat all published systems on knowledge-update questions
Who Should Read
Agent developers frustrated that their LLM keeps reasoning from assumptions already disproved during long sessions
Core Mechanics
- Memory is two problems: retrieval and current truth
- Vector DBs find past notes relevant to a question.
- They don't know if a note was later disproven or if conclusions built on it are now invalid.
- The LLM extracts facts, the database reasons
- The LLM turns logs, debugger output and prose into structured facts.
- A Datalog engine (Lemmalog) derives and maintains conclusions from rules.
- Removing a fact auto-invalidates its conclusions
- It tracks which facts support each conclusion, keeping it if another derivation remains.
- With no support left, the conclusion disappears.
- You can ask why it believes something
- Every conclusion carries provenance (which observations and rules produced it).
- A conclusion without provenance isn't part of the maintained state.
- Facts get validity intervals so history survives
Community Reactions
- It led on knowledge updates
- On LongMemEval Knowledge Update, Lemmalog scored 0.579 vs PropMem 0.528 and Full Context 0.202.
- Multi-Session was weak at 0.211 vs PropMem 0.582.
- On full LoCoMo it ranks third
- Three runs gave F1 0.533±0.001, behind PropMem 0.605 and OpenClaw 0.557, and Full Context at 0.542.
- Adversarial false-premise questions scored 0.707 vs 0.509 for Full Context.
- Failures were extraction misses, not reasoning
- Multi-session failures were mostly facts never extracted rather than mis-connected.
- Extraction used Claude Sonnet 4.6; later stages used the benchmark's standard readers and judges.
- Commenters recognized the stale-facts problem
- One commenter said Claude records things everywhere and treats disproved facts as true.
- Another said an LLM kept resurfacing a ruled-out cause in a hardware failure investigation.
How to Apply
- Add a retraction list to your agent notes
- Today, add 'rejected assumptions' and 'conclusions depending on them' sections to CLAUDE.md or your notes.
- Instruct the agent to remove or mark invalid any dependent conclusion when an assumption is overturned.
- Split memory into retrieval and current state
- Keep your vector memory and add a separate store holding only currently-true facts.
- Have answers prefer the current state and use retrieval as support.
- Require evidence IDs on every conclusion
- Make supporting observation IDs a mandatory field when the agent writes a conclusion.
- Add a validation step that rejects unsupported conclusions.
- Check whether your grounding instruction causes refusals
- If you added anti-hallucination prompts, measure refusal rate on answerable questions.
- Write: refuse if the premise is absent, but reason if evidence exists and needs counting, comparing or ordering.
Try It
# Paste at the start of a Claude or ChatGPT chat (simplified version of the post's method: mimics Datalog via prompt)
You are a research assistant. Maintain a 'maintained state' in this format throughout the conversation.
- FACTS: numbered observations (F1, F2...). Each marked valid/retracted
- CONCLUSIONS: numbered (C1...). Each must list its supporting FACT numbers
- Rule: when a FACT is retracted, immediately mark invalid every CONCLUSION that depends only on it. Keep conclusions that still have other valid support.
- Never write a conclusion without supporting fact numbers.
- End every reply with the updated state.
Topic: {{research topic}}
I'll now give observations; update the state. First observation: {{observation 1}}
Next to try: later say '{{observation 1}} was wrong' and ask which conclusions became invalid and why.Terminology
Related Papers
Same Simulation, Different Evidence: Where Retrieved Tool Output Costs LLM Agents Accuracy
Saving long tool output to files cut GPT-5.1 accuracy by 11.3 points; naming the authoritative file restored it.
Fake News, Real Crashes: Information Injection Attacks on LLM Financial Trading Agents
Fake headlines hijacked LLM trading agents 62% of the time versus 14% for prompt injection.
Harness Engineering 101: The LLM is the brain, the harness is the body
An agent is a loop managing a JSON array; 16 chapters build one from scratch
Harness2 by Google Research – Recursive Agent Harnessing
Recursively refining the harness with fixed model weights raised benchmark scores by up to 11.8 points.
Ousted Savannah police officer gave ICE agent husband access to Flock system
A police officer shared her Flock login with her ICE-agent husband; an audit found 983 searches and she was fired
Tmux and Claude Code: Sessions, Send-Keys, and the Ceiling
Running Claude Code agents in tmux works well, but limits appear around four agents.
Related Resources
- https://pwning.systems/posts/llm-memory-program-analysis/
- https://en.wikipedia.org/wiki/Cyc
- https://en.wikipedia.org/wiki/Answer_set_programming
- https://github.com/deepclause/deepclause-sdk
- https://github.com/deepclause/deepclause-pi
- https://github.com/cookiengineer/exocomp
- https://github.com/cookiengineer/gobayashi
- https://github.com/cookiengineer/gonano
- https://mirekrusin.com/cave