Claude Code finished 59 of 90 tasks. I changed one file, and it finished all 90.
270 runs across haiku, sonnet, and opus. The only difference was CLAUDE.md, cleaned up by an open-source tool that reads what the agent wrote down against what actually happened.
⭐ Repo: https://github.com/mvplab-ai/agentdream
I ran Claude Code 270 times on the same ten coding tasks.
The only thing I changed between runs was one file: CLAUDE.md, the notes the agent keeps about the project.
With notes that had drifted the way real notes drift, Claude Code finished 59 of 90 tasks correctly.
After a free, offline cleanup pass with no model involved: 78 of 90.
After a cleanup pass that used a model: 90 of 90.
Same harness. Same models. Same tasks. Same code. One file different.
This is the write-up of what I built, what I measured, where the result is weaker than it looks, and the bug my own benchmark caught in my own tool right after I shipped it.
The tool is called AgentDream. It is open source, MIT licensed, and on PyPI. The code, the benchmark, and every number below are on GitHub: https://t.co/FT4tDpSfSx. Everything below can be reproduced with one command.
The problem nobody is maintaining
Every serious agent setup now has memory. Claude Code has CLAUDE.md and a per-project memory folder. Other harnesses have their own version. The agent writes notes during a session so the next session starts smarter.
Nobody maintains those notes.
They only grow. An agent writes "the API listens on port 8080" in December. In February it writes "the API listens on port 9090" in a different file. Both notes are still there in March.
It writes "run the tests with make test." Someone deletes the Makefile. The note stays.
You tell it, "Don't use dataclasses; we prefer plain dicts." Two months later you change your mind and say so in a session. The agent says "understood." The note still says don't.
That last one is the dangerous kind, and I will come back to it, because the data on it is the most interesting thing I found.
The example that shipped with the first version of Agent Dream is a nod to the Claude Plays Pokémon story. An agent has a note: "The PokéCenter is north of the gym." It walks north. Nothing there. It walks north again in the next session. Nothing there. In a third session it finally goes south and finds it.
The note still says north.
The transcripts contain everything needed to fix that note. The agent failed on it, in writing, four times, and then stated the truth. But transcripts are not memory. Nobody goes back and reconciles the two.
That reconciliation is the whole product.
What agentdream does
It reads your agent's memory and its recent session transcripts while the agent is idle, and it stages a corrected copy for you to review.
Anthropic calls this idea "dreams" in their managed agents platform. Letta and UC Berkeley published a paper on it called "Sleep-Time Compute." AgentDream is an independent open-source take on the same shape of workflow, built to run on your own machine against memory that lives on your own disk. It is not affiliated with either.
A dream is seven phases, in order:
1. Load: read the memory store and the transcripts. Read-only. Every transcript message keeps a file and line reference.
2. redact: scrub API keys, tokens, passwords, and card numbers before anything is analyzed or sent anywhere.
3. Limits: trim oversized inputs with a notice, or stop if you asked it to fail instead.
4. Consolidate: merge duplicate notes, keep the newest of two dated values, and resolve reversed preferences.
5. Verify: compare each note with what the transcripts show, and correct the ones the evidence contradicts.
6. Insights: Record what recurs across sessions.
7. Write: put the new store, a report, and a diff into a staging folder.
Then it stops.
Nothing is applied. You get a report where every change is an operation with its own ID, a reason, and a confidence, and for corrections, the exact transcript lines that prove it. You accept all of it, some of it, or none of it. An accept takes a backup first. One command restores it.
For the PokéCenter, the report says, "Corrected from transcript evidence, north to south, three supporting observations, four refuting, and then it quotes them." "Walked north of the gym for 20 steps. No PokéCenter here, only tall grass." The file and line number are attached.
Two engines can do the analysis.
The default is rule-based. No model, no network, no API key, no dependencies at all. The core of the package is the Python standard library only. It handles a 5,000-entry store in seconds.
The other is any model you point it at: Anthropic, OpenAI-compatible servers, Ollama, LM Studio, vLLM, or your existing Claude Code login. Model output is treated as untrusted. If it names a note that does not exist, the proposal is dropped. If it cites a transcript line that does not exist, drop it. If it quotes a line wrongly, the quote is replaced with the real text and flagged. A correction with no verifiable evidence is downgraded to a flag.
That is the tool. The question I actually cared about was whether any of this makes an agent do better work.
The experiment
I did not want a benchmark where a model grades a model. So I built one where code checks the result.
The script generates a small Python project: an order service with pricing, a client, a server, and some tests. It also generates a CLAUDE.md that has drifted in eight specific ways, and five earlier sessions in Claude Code's own transcript format, in which the agent runs into each problem and finds the truth.
The eight drifted notes:
- "Runtime settings live in config/settings.json." False. That file is a leftover; nothing reads. The real settings are in orders/defaults. py.
- "Test fixtures live in tests/data/." That directory does not exist. They are in tests/fixtures/.
- "Run the test suite with make test." Written twice, in two wordings. The Makefile was removed.
- "Don't use dataclasses for new models." The user reversed this in a later session.
- "Don't use the logging module; print is enough." Also reversed later.
- "The staging database host is db-staging-1.internal." Decommissioned. It is db-staging-3 now. This fact is not in the code anywhere.
- "The API server listens on port 8080," sitting next to a newer note that says 9090.
- "CI fails below 80% coverage," sitting next to a newer note that says 90%.
Two more notes are correct and stay correct.
Then ten tasks. Eight of them run into one of the drifted notes. Two depend only on the correct notes. Those two are controls: if a dream damages good notes, the controls fail.
Each task is a plain request, the kind you would type. "Raise the request timeout to 45 seconds." "Add an Address model with street, city, and postcode fields." "Add a script that prints the Postgres DSN for the staging database."
Each task has a checker written in code. Does the function exist and return the right value. Do the tests pass. Did the setting of the program actually read change? Does the script name the right host?
Three versions of CLAUDE.md:
- The drifted notes, untouched.
- The notes after a rule-based dream. No model. Everything it proposed was accepted.
- The notes after a model dream. Everything it proposed was accepted.
Then Claude Code, headless, in a fresh copy of the project for every run. The copies are byte-identical except for CLAUDE.md.
Three models: Haiku 5.5, Sonnet 5.5, Opus 5.5. Three runs per task per memory file per model.
10 tasks × 3 memory files × 3 runs × 3 models = 270 runs.
The results
Tasks passed, out of 30 per model:
Haiku 5.5
- Drifted notes: 21
- After a rule-based dream: 27
- After a model dream: 30
Sonnet 5.5
- Drifted notes: 18
- After a rule-based dream: 24
- After a model dream: 30
Opus 5.5
- Drifted notes: 20
- After a rule-based dream: 27
- After a model dream: 30
All three, out of 90
- Drifted notes: 59
- After a rule-based dream: 78
- After a model dream: 90
Pass and fail were identical across all three runs in 89 of the 90 cells. The one exception: Opus on the timeout task with drifted notes, which passed twice and failed once.
That stability is the reason I am comfortable publishing a result built on three runs per cell. This was not noise. The same note produced the same outcome, run after run.
The whole thing cost $15.95. Haiku was 45 cents. Opus was $10.97.
The finding: there are two kinds of wrong notes.
The headline number is not the interesting part. The breakdown is.
Wrong notes split cleanly into two groups, and the models treat them completely differently.
Group one: notes about the code.
A dead test command. A directory that does not exist. An old port next to a new one. An old coverage threshold next to a new one.
Runs passed with the drifted notes: 36 of 36.
Every model, every run. The agent tried to make a test, watched it fail, found the right command, and carried on. It looked for tests/data, saw it was not there, and found tests/fixtures. It read the port out of the server module.
These notes cost a few turns. They cost zero tasks.
Group two: notes that state a preference or a fact about the outside world.
"Don't use dataclasses." "Don't use the logging module." "The staging host is db-staging-1."
Runs passed with the drifted notes: 0 of 27.
Zero. Haiku, sonnet, and opus. Every single run.
Think about why. When a note says "run make test" and the make test fails, the repository is arguing with the note, and the agent listens to the repository. When a note says "we don't use data classes here," nothing argues back. There is no file to check. The note is the only source of truth the agent has, and the note is wrong.
Opus did not catch it. It is not a capability problem. No model can check a note against something that is not in the repository.
After a model dream, those same 27 runs: 27 of 27.
That is where the result comes from. The agent was never going to catch those by being careful, and a dream is the only step in the loop that reads the transcript where you changed your mind and goes back to fix the note.
The note that split the models
One task sits between the two groups, and it is my favorite result in the set.
The note says runtime settings live in config/settings. json. That file exists. It contains a timeout. It looks exactly right. Nothing in the program reads it.
The task: raise the request timeout to 45 seconds.
Sonnet, with the drifted notes: 0 of 3. Each run finished in three turns. The program still used 30 seconds.
Haiku: 3 of 3. Opus: 2 of 3. They looked further and found the real setting.
So across the three models, that is 5 of 9 with the drifted notes, 6 of 9 after the rule-based dream, and 9 of 9 after the model dream.
Fast and confident and wrong is the worst failure mode an agent has, and a plausible wrong note is what triggers it. The run did not error. It did not ask. It finished.
What a dream it did not do.
It did not make the agent faster. I expected it to. It did not.
Mean turns per task:
Haiku: 8.2 with drifted notes, 7.6 after rules, 7.9 after a model dream.
Sonnet: 3.7, then 3.5, then 4.2.
Opus: 5.9, then 6.2, then 6.3.
Flat. Slightly worse in places. Cost per task did not move either.
One detail explains part of it. The model dream did more than fix notes. It added two insight notes of its own, and one of them told the agent to verify a noted path, command, port, or host before relying on it.
The agent took that seriously. On Sonnet, the health-check task took 3.7 turns with drifted notes, 2 turns after the rule-based dream, and 8 turns after the model dream. Same correct answer every time. Four times the work.
So the claim I can defend is narrow: a dream changes whether the task is done correctly. It does not buy you speed. And you should read the insights a dream adds as carefully as its corrections, because a cautious note makes a cautious agent.
The controls held. Both control tasks passed in all 54 runs across the three memory files. No task that passed with drifted notes failed after either dream.
What the free version gets you
The rule-based dream costs nothing and runs in a fraction of a second. It took 59 of 90 to get to 78 of 90.
It recovered 19 of the 31 failures, and 18 of those came from one capability: it recognizes a reversed preference. It sees "Don't use dataclasses" in the notes, sees "Actually, let's use dataclasses for new models from now on" in a later session, and flips the note, keeping one line of history and the transcript reference.
What it cannot do: read "db-staging-1 was decommissioned last month" as a correction to a hostname, or read "nothing reads that file" as a correction to a path. That needs comprehension, and comprehension needs a model.
It also missed one I expected it to get. It left the 80% and 90% coverage notes side by side. All nine runs with that file still picked 90%, so it cost nothing in this test. I did not go back and tune the engine to fix it. Tuning your tool against your own benchmark until the number looks good is how you end up with a number that means nothing.
A second measurement, and a result I did not like.
I built a second test to check the first one from a different angle.
A generated memory store: 130 notes, 50 sessions, 80 facts, and every defect labelled in advance. Duplicates, near duplicates, stale values, notes the transcripts refute, reversed preferences, paraphrases, and controls.
Then a model in the agent's seat. It gets the notes and nothing else, and one question per fact. "Which port does the staging gateway service listen on?" "Should Poetry be used for dependency management?" Code checks the answers.
Questions answered correctly, out of 80:
- Before the dream: 60
- After the safe auto-update policy only: 60
- After accepting everything: 80
Look at the middle line.
agentdream has a safe mode for the Claude Code hook. It automatically applies only the low-risk changes, duplicate merges, and stale-value replacements, and leaves the transcript-based corrections staged for a human. I built it. I was pleased with it.
It did not change the model's answers at all. 60 before, 60 after.
A capable model is not confused by duplicates. It is not confused by two dated values. It picked the newer date by itself, 40 questions out of 40, with no help from me.
What it got wrong was all 20 questions about a refuted note or a reversed preference. And safe mode, by design, does not touch those.
So here is what safe mode buys you: a store that is 13% smaller, on every session, forever. That is real. It is not correctness. The answers only change when you accept the corrections, which is the part that needs your eyes.
I put that in the docs in plain words. If I only published the flattering numbers, you would have no reason to trust the other ones.
The bug my own benchmark found
I shipped 0.1.0. Then I wrote the first benchmark.
It had controls in it: ten notes of identical shape, about ten different things. "The on-call rotation for partner search changes every Monday." "The on-call rotation for sandbox ledger changes every Monday." Ten teams, ten notes, all true, none of them duplicates.
0.1.0 merged nine of them into one.
The duplicate rule accepted any two notes with enough shared words. Those notes differ in two words out of nine. Confidence 0.85. Reason given in the report: "Notes say the same thing."
On that workload, the version I had already published kept 2 of 10 unrelated notes.
A tool whose entire job is to protect your agent's memory was deleting it.
And a merge is exactly the kind of change the safe auto-update applies without asking you.
The fix: the rule now refuses to merge two notes that line up word for word except for a swap of unrelated words on both sides. "Before committing" versus "before every commit" still merges. "Billing queue" versus "mail queue" never does.
The same benchmark caught a second one. A correction rewrote "north of the west stairwell" as "south of the south stairwell." It replaced every directional word in the note, including the one that was part of a name.
Both are fixed in 0.1.1, each with a regression test. The release notes tell 0.1.0 users to check any merge they accepted.
The lesson I took: a benchmark that only contains problems to fix would have scored those false merges as a win. Smaller store, fewer notes, number goes up. The controls are what caught it. If your evaluation has no way to detect harm, it is measuring enthusiasm.
Why it is built the way it is
Every design decision comes from one assumption: this tool will be wrong sometimes, so being wrong has to be cheap.
The input is never modified by a dream. Adapters load read-only. SQLite opens in read-only mode. Output goes to a separate staging folder, and the adapters refuse to write onto their own input path. The test suite hashes every input file before and after for every adapter.
It is a dry run by default. You have to accept or explicitly opt in.
Accepts backing up first, refuses to run if the store changed since the dream, and swaps the new store in by renaming. If it fails halfway, the original goes back.
Operations have stable IDs. They are content hashes, so the same inputs give the same IDs on every run, and you can accept by ID.
Secrets are redacted before analysis, again over every prompt sent to a model, and again over every quote in a report. Thirty-plus patterns, plus a check for long high-entropy tokens.
It has zero runtime dependencies. The HTTP calls to model APIs use the standard library. There is a small TOML parser bundled so it works on Python 3.10 without an extra package. If a tool is going to read your agent's memory and your session transcripts, you should be able to audit what it imports. The answer is nothing.
How to use it
Install it:
pip install agentdream
Run a dream by hand, on any agent's memory:
agentdream dream --memory ./memory --sessions "./logs/*.jsonl"
That is a dry run. Then read the report, and accept what you agree with:
agentdream show <job-id>
agentdream accepts <job-id> --only correct-2ec6281c
agentdream restore <job-id>
It reads markdown folders, JSON, JSONL, and SQLite. It reads Claude Code session files, OpenAI-style message JSON, generic role and content JSONL, and plain text transcripts, and works out which is which.
If you use Claude Code, there are three ways in.
The skill. Run agentdream install-claude-skill, then type /dream. Claude finds the project's memory and recent sessions, runs a dry-run dream, walks you through the report, reads the cited transcript lines before recommending a correction, and applies only what you approve.
The hook. Run agentdream install-claude-hook --every 3 --safe. After every third session a dream runs in the background. Merges and stale-value replacements are applied with a backup. Corrections and insights wait for you. The hook returns in about a tenth of a second and never blocks or fails your session.
The MCP server. Run claude mcp add agentdream -- agentdream serve-mcp. Claude gets dream, show_report, and accept as tools. The same server works in Cursor.
Given what the data says, here is how I would actually set it up. Turn on the hook so dreams are always staged. Do not expect safe mode to make your agent more correct. Once a week, type /dream and read the corrections, because those are the ones that change outcomes.
What this does not prove
I would rather you hear the weaknesses from me.
The tasks were written to run into the drift. I designed ten tasks, eight of which collide with a note I had deliberately broken. This shows which kinds of wrong notes cost a task and that a dream removes the cost. It says nothing about how often your notes are wrong. If your CLAUDE.md is clean, a dream will change very little, and it should.
One small project, one author. I wrote the project, the notes, the sessions, the checkers, and the tool. The sessions state each truth plainly: "The staging database host is db-staging-3.internal now." Real transcripts are messier, the truth is buried in tool output and half-sentences, and a dream will recover less from them. I do not know how much less. That is the next thing to measure.
Three runs per cell. Enough to see that outcomes are stable. Not enough to say anything fine-grained about turn counts.
One harness, one vendor. Claude Code 2.1.332 and three Claude models. I would expect the two-kinds-of-note finding to hold elsewhere, since it follows from what the agent can and cannot check. I have not tested it.
"Pass" means the checker passed. The checks are narrow on purpose. They ask whether the model is a dataclass and whether the script names the right host. They do not grade code quality.
The rule-based engine only reads English, and it reads plain English best. It matches the words. Two notes that state one fact in unrelated wordings stay as two notes: it merged 0 of 10 paraphrased pairs in the store benchmark. The model backend merged 10 of 10. I looked hard for a rule that could do it, and every candidate would also merge different facts about the same subject, which is the exact bug I had just fixed. I left it out.
The part worth remembering
If you take one thing from 270 runs, take this.
Your agent will catch its own wrong notes about the code. It checks. The repository pushes back.
Your agent will not catch a wrong note about what you want or about a fact that lives outside the repository. Nothing pushes back. It will follow that note every time, at every model size, and it will not tell you.
Those are the notes that go stale when you change your mind in the middle of a session and nobody updates the file.
The transcript knows. The memory does not. Something has to reconcile the two while the agent is not busy.
That is what a dream is for.
agentdream is open source: https://github.com/mvplab-ai/agentdream
Install it with pip install agentdream. The full benchmark, with every number in this post, is in docs/BENCHMARK.md in the repo. The site at agentdream. Dev has a version of the review screen you can click through. The evaluation is one command: python evals/claude_code/run.py.
Run it on a model I did not test. Run a dream on your own notes and tell me what it got wrong.
What is the oldest note in your agent's memory that you already know is false?
⭐ If agentdream is useful, star it on GitHub so other agent builders find it: https://github.com/mvplab-ai/agentdream