Anthropic's Agent Memory: Four Layers, a Dreaming Pass, and the Pokémon Proof That Writing Less Wins
How Claude's Memory Is Designed: A Four-Layer Memory Stack and an Offline Sorting Called "Dreaming"
By ENCI
First, the conclusion: Anthropic's November 6 engineering long article breaks agent memory into four layers—raw conversation logs, memory notes, knowledge representations (wiki), and resident context. While working, Claude records as it goes, guessing what matters; when idle, it runs an offline task called dreaming, which checks notes line by line against logs. The real value isn't in "remembering a lot" but in "knowing what not to remember": in the Pokémon experiment, the model that wrote 413 memory files got 1 badge, while the one that wrote 9 files got 4.
Table of Contents
- The Four-Layer Stack
- Memory During Work Is a Prediction About the Future
- 413 Files vs. 9 Files
- Give Rules, or Give Judgment
- What Dreaming Computes
- From 13% to 48%, and the Unsolved 52%
- What This Design Still Doesn't Solve
- Three Judgments, Three Bases
- What It Means for People Building Agents
1. The Four-Layer Stack
Anthropic arranges agent memory into four layers by "persistence" and "information density." The higher the layer, the more refined, more expensive, and faster to load.
| Layer | Content | How It's Produced |
|---|---|---|
| Layer 1 | Raw conversation logs | Complete record of what was said, seen, and done in a session, unprocessed |
| Layer 2 | Memory notes | Observations, corrections, and behavioral rules distilled from logs |
| Layer 3 | Knowledge representations | Cross-session synthesized wiki pages with interlinks |
| Layer 4 | Resident context | Notes and wiki entries promoted to the top, auto-loaded at the start of each session |
The four layers aren't parallel—they form a processing pipeline: logs are the raw material, notes are the semi-finished product, wiki is the finished product, and resident context is the pages sitting on the desk, ready to grab.
flowchart TB
A[Layer 1 Raw Conversation Logs] -->|distill| B[Layer 2 Memory Notes]
B -->|cross-session synthesize| C[Layer 3 Knowledge Representations wiki]
C -->|promote highest-frequency entries| D[Layer 4 Resident Context]
D -->|auto-load each session| E[Next Session]
E -->|produce new logs| A
B -->|validate against logs during dreaming| B
classDef raw fill:#E8F0FE,stroke:#1A73E8,stroke-width:2px,color:#0B1F3A
classDef note fill:#E6F4EA,stroke:#1E8E3E,stroke-width:2px,color:#0B2412
classDef wiki fill:#FEF7E0,stroke:#E37400,stroke-width:2px,color:#3A2400
classDef live fill:#FCE8E6,stroke:#D93025,stroke-width:2px,color:#3A0B08
classDef session fill:#F3E8FD,stroke:#8430CE,stroke-width:2px,color:#231038
class A raw
class B note
class C wiki
class D live
class E session
There's a loop easy to miss: notes get written back, validated, and replaced, but the raw material (logs) itself never changes. Anthropic states this tightly in the Dreams documentation—the input memory store is never modified; the output is a brand-new store that can be discarded if unsatisfactory. This design effectively gives memory operations an undo.
Sources for cross-checking: Anthropic: The components of agent memory, Claude platform Dreams documentation. The broader idea of "offline sorting" traces back earlier to Letta and UC Berkeley's sleep-time compute paper, which Anthropic also cites as an intellectual source.
2. Memory During Work Is a Prediction About the Future
Layer 2, "memory notes," is easy to mistake for a running summary—it's not.
Anthropic's phrasing is direct: writing a rule is a prediction that the pattern will be used again; writing a verified fact is a prediction that a future session will rely on it directly without rechecking. So memory inherently carries a gambler's element—if the bet is wrong, the wrong entry gets read into subsequent sessions as a premise.
That leads to an interesting corollary: memory's value isn't about coverage; it's about predictive accuracy. Recording "the user prefers concise answers" is a useful prediction; recording "there are 3 enemies on screen right now" is a useless prediction, because the next turn the screen will tell you itself.
The text also draws a boundary: this memory does not include weight updates, does not include in-context learning within a single conversation, and does not include context compaction. It refers specifically to the portion that persists across sessions and exists as readable text.
3. 413 Files vs. 9 Files
To judge "what's worth remembering," Anthropic ran an experiment with Pokémon Red. Each model got a read/write memory folder and decided on its own what to write.
The results are stark:
- Claude Sonnet 3.7 wrote 413 memory files across 225 folders and earned 1 badge.
- Claude Fable 5 wrote just 9 files in 2 folders, plus a top-level global.md, and earned 4 badges.
Where's the difference? Sonnet 3.7's assumption was "anything could be useful," so it archived every battle, every item, every NPC separately. But Pokémon's game state constantly changes—its detailed records went stale the moment they were written, and the longer it went, the more time it spent searching its own memory. Around step 10,000, it opened a fourth "main memory" folder, then in the next 17 steps created 6 files and deleted 9, without taking a single game step.
Fable 5's judgment was the opposite: anything readable from the screen each turn isn't worth writing. Money, location, current HP—read it and it's there; saving it just crowds attention. It recorded what the screen can't show: strategy, plans, verified rules. The global.md served as a dashboard for current goals, the locations folder held route plans, and the gameplay folder collected trial-and-error lessons like "after failing to catch a Magikarp with seven consecutive balls, try changing the rhythm."
One sentence summarizes the experiment: memory quality is defined by "what you decide not to record," not by "how much you recorded."
4. Give Rules, or Give Judgment
Many teams building memory systems start with rules: only record failures, only record user preferences, only record three types of information. Anthropic tried this and got the opposite of intuition.
They added a "only record failures" rule to Opus 5 and Opus 4.7, and both models' memory gains dropped substantially. For strong models, pre-defined rules block useful information the model could judge on its own. The original text says: tell Claude what memory is for, but don't tell it how to use it.
Weak models invert. Sonnet 4.6 often didn't read its own memory files or verify "why did I get the last answer wrong." Adding "read memory before answering, verify hypotheses first" nearly doubled its baseline score. Sonnet 5 does this without prompting—nine times out of ten it reads memory proactively.
The product takeaway: the same memory architecture acts as an amplifier on strong models and a noise collector on weak models. Don't expect a more sophisticated memory system to compensate for the model's own judgment.
5. What Dreaming Computes
Dreaming isn't mysticism—it's an asynchronous batch task. Each run does three things:
- Extract new notes from recent sessions—user preferences, recurring patterns, mistakes made, corrections received.
- Use notes and historical sessions to synthesize new wiki entries; merge duplicates, replace stale entries with the latest values.
- Promote the most reliable notes and wiki entries into resident context, loaded at the start of the next session without retrieval.
Several engineering constraints worth remembering: one dreaming run can consume 1 to 100 sessions; runtime ranges from minutes to hours depending on session count; the input store is untouched, the output is a new store; you can pass instructions for high-level guidance, but it "synthesizes" rather than "line-edits"—writing "change the number in paragraph 3 to 5" will basically not take effect.
The most typical fix case comes from Pokémon. Claude used a Pokémon Center at the entrance of Mt. Moon as a landmark, and at some point recorded the center's location as the east side. Walking out the door, it announced "Mt. Moon is behind me" and marked the task complete—the actual direction was entirely wrong. A few steps later it hit a one-way staircase and got sent back; the navigation tool didn't show elevation, so it reassured itself "I'm too far west" and kept going the wrong way.
After one dreaming run, Claude took the notes against the raw session logs, found its judgment didn't match the action trajectory in the logs, and rewrote that note. After the correction, it walked straight back to the cave entrance and eventually reached Cerulean City. In the uncorrected run, it fell on the same staircase three times; on the fourth fall it wrote "I'm not looping anymore, I'm stopping," retreated all the way back to Pewter City, and never reached its destination.
That's what "using logs as ground truth" means: when the model can't think its way clear, the raw record thinks it clear.
6. From 13% to 48%, and the Unsolved 52%
Anthropic also ran a long-cycle wiki test: using a corpus of roughly 350,000 files and 420 million tokens of technical documentation, it ran 128 offline sortings and asked a set of questions requiring cross-document synthesis.
- Relying only on the immediate state at session end, wiki answer accuracy was about 13%.
- After 128 dreaming runs, it rose to 48%.
- Adding retrieval on top, it rose to 61%; retrieval alone without wiki gave 53%.
- Tokens consumed per answer were about 20,000 fewer than directly browsing raw files.
The 48% figure needs to be placed correctly: it's nearly four times 13%, showing offline sorting does accumulate knowledge. But another way to put it: after 128 dream runs, 52% of wiki answers are still wrong. The original text acknowledges this and points out a nastier property—if an early wrong rule is never positively displaced by later experience, it can stay in the wiki forever.
That explains why dreaming is more reliable in domains where errors produce immediate feedback. Writing code, running tests, playing games—you know immediately when you're wrong. Making industry judgments, writing market analysis—nobody tells you you're wrong, and the erroneous note keeps accumulating.
One more note on source levels: the four-layer structure, Pokémon experiment, and Mt. Moon case I verified against Anthropic's original text; the 13% to 48%, 61% vs. 53%, and ~20k token reduction figures come from a third-party summary of the original text, which doesn't fully expand on the page. I cite them per that summary. The CL-Bench numbers (Opus 5.5 from 0.655 to 0.838, Sonnet 4.6 from 0.330 to only 0.364) also come from that summary.
7. What This Design Still Doesn't Solve
Four items, ordered by impact.
First, accessibility. Dreaming currently exists only in Claude Managed Agents' research preview, requiring access requests and a specific beta header. Teams using the standard API or third-party frameworks can't use this mechanism yet.
Second, the accuracy ceiling. 48% is the endpoint of 128 sortings, not a midpoint. Pushing higher by adding more runs hits diminishing returns; you'd need a stronger model or cleaner input.
Third, reproducibility. Memory migrates across sessions; the same question asked at different times can give different answers because different notes are retained. For businesses needing stable output, this needs extra testing.
Fourth, audit cost. The input stays unchanged and the output is newly created, meaning each dreaming run produces a new store. The more often you run it, the more versions you must review—the tokens saved might be swapped for human review time.
8. Three Judgments, Three Bases
| Key Judgment | Basis | Counter-example (common misreading) |
|---|---|---|
| Memory's core is "what not to record" | 413 files = 1 badge, 9 files = 4 badges | Assuming more memory is better, storing screen-visible info too |
| Dreaming isn't autonomous thinking; it's reconciliation | Mt. Moon case: only checking notes against raw logs caught the direction error | Assuming the model can self-correct by thinking when idle |
| Memory is an amplifier of model capability | Strong models gain visibly; weak models gain almost nothing | Trying to use a complex memory architecture to compensate for the base model's judgment |
The second row deserves expansion. "Dreaming" is essentially a verification pass with ground truth: logs are the only raw facts untouched by the model; notes are the model's inferences. Only by comparing inferences to raw facts can you find errors. Without logs to check against, dreaming is just making the model guess again.
9. What It Means for People Building Agents
If you're building agent products, this long text gives at least three directly usable things.
One, layer it. Don't stuff everything into one memory store. Keep logs raw, distill notes, synthesize wiki, and put only the highest-frequency entries in resident context. Layers keep retrieval costs down.
Two, solve "what not to record" first. In implementation, ask: can this info be obtained next time by reading the environment directly, without memory? If yes, it shouldn't occupy a memory slot. This one rule trumps any memory framework.
Three, don't replace judgment with rules. Early on, a little steering can get the model in the door, but don't hard-code "only record failures" or "only record three types." The stronger the model, the more you should delegate significance judgment to it.
One final cost note: dreaming is billed by token, and cost grows roughly linearly with the number and length of input sessions. The original recommends trying with small batches first, then scaling after satisfied. This advice applies to any offline-sorting system—first prove someone actually reads the output before running it nightly.
This column, "AI Agent Tools," covers agent memory, tool calling, and runtime mechanics, each piece grounded in primary documents or verifiable experiment data, updated weekly. To read in order, subscribe at the column page.