
The Components of Agent Memory
Anthropic lays out a four-layer agent-memory hierarchy and shows how dreaming improves recall, corrects errors, and builds navigable knowledge.
Why memory is becoming an agent infrastructure layer
Source: The components of agent memory, Anthropic, November 6, 2026.
Søren Kierkegaard wrote that life can only be understood backward, but it must be lived forward. Designing memory for AI agents presents a similar tension.
Humans encode memories continuously. The hippocampus captures experience in the moment so that some information is immediately available, but only a subset is consolidated into long-term knowledge. Much of that consolidation appears to happen offline. During sleep and quiet rest, the hippocampus replays recent experience and gradually integrates selected memories into the neocortex.
Agent memory can use a similar division of labor. Agents already produce logs and transcripts as they work. Letta and UC Berkeley researchers have proposed sleep-time compute, in which a model uses idle time between interactions to reorganize its existing context. The same idea can help an agent reflect on logs, correct mistakes, and produce new notes or representations. This process is often called dreaming.
Anthropic has found dreaming useful in giving Claude effective memory. This article explains how the company now thinks about agent memory, reviews evaluations of its different components, and examines what each layer contributes.
A four-layer memory hierarchy
Here, agent memory means knowledge Claude gains from experience and retains between sessions, including interactions with users and work on assigned tasks. It is stored as context Claude can read later.
The definition excludes other ways a model learns or manages context. Weights can change during training. In-context learning operates within a single conversation. Compaction replaces older turns with summaries so work can continue in a new context window.
The bottom layer is the transcript. It records events and can be searched, but it does not automatically place the right information in front of Claude.
The second layer contains memory notes. Claude writes down salient observations, rules, failure diagnoses, or next steps. Notes are compact, but their quality depends on Claude's judgment about what deserves to survive.
The third layer contains memory representations, such as a linked wiki. These do more than compress information: they give Claude a map for navigating a growing body of knowledge.
The top layer is injected context. The agent harness loads a small amount of material at the start of every session, so Claude does not need to search for it or even know that it exists. Because this content consumes tokens in every session, it must remain small and reliable.
Writing memory at the moment of experience
In the human brain, chemical signals before, during, or after an experience can mark a memory as important. Marked memories are replayed more often during offline periods, helping stabilize and integrate them into long-term memory.
Claude can similarly tag salient events while a session is active so they are easier to find later, or write them directly to a memory store such as a folder of notes.
The hard question is how to identify what matters in the moment, before the future that determines its importance is known.
Memory is a prediction about future needs
Writing a memory is sometimes a prediction. A rule predicts that a pattern will matter again. A verified fact predicts that a future session will use it without checking again. As Claude has improved, so has its ability to make these predictions.
Continual Learning Bench 1.0 provides a direct test. One task asks Claude to answer a series of questions from a database. After every answer, the environment reveals the correct result, and Claude can write a memory for later questions.
A complete learning loop records the failure, proposes theories about what went wrong, tests those theories, and converts the result into a rule for future answers.
Anthropic ran the task with Claude Managed Agents. Every question began in a fresh session. The only continuity came from a memory directory mounted across sessions. Models differed substantially in whether they formed a learning loop.
| Model | Stateless baseline | With memory | Gain |
|---|---|---|---|
| Claude Opus 5.5 | 0.655 | 0.838 | +0.183 |
| Claude Sonnet 5.5 | 0.644 | 0.833 | +0.189 |
| Claude Opus 5 | 0.564 | 0.828 | +0.264 |
| Claude Opus 4.7 | 0.383 | 0.700 | +0.317 |
| Claude Sonnet 5 | 0.306 | 0.610 | +0.304 |
| Claude Sonnet 4.6 | 0.330 | 0.364 | +0.034 |
Sonnet 4.6 generated theories about incorrect answers, but scattered several untested guesses across its memory directory. Opus 4.7 began consolidating notes into one reference document and marked which facts had been checked. Sonnet 5 marked answers after grader confirmation and wrote corrections after mistakes.
Opus 5 was among the first tested models to close the loop. Most entries included a rule, evidence that the rule was true, answers to earlier questions, and warnings about traps discovered along the way.
Opus 5.5 and Sonnet 5.5 also closed the loop, using memory to retain validated answer rules. With memory, both scored close to Opus 5, although their baseline performance without memory was already higher.
Claude has learned to judge salience
A second evaluation uses Pokémon Red, a game that stresses long-horizon navigation and recovery. At the start of each run, the model receives a folder of memory files that it can read and write during play.
Anthropic compared Sonnet 3.7 and Fable 5 around 10,000 steps into the game. The clearest difference was what each model considered worth storing.
Sonnet 3.7 assumed everything might matter and recorded indiscriminately. It often created a separate file for every battle, collected item, and non-player character. By this point, it had written 413 memory files across 225 folders and earned one badge.
Fable 5 wrote nine files in two folders plus a top-level global.md, yet earned four badges.
Sonnet 3.7's approach was costly because game state changes constantly. A detailed record quickly becomes stale, forcing the model to spend more time and context combing through memory instead of playing. Around step 10,000, it started a fourth folder of master memory files. Over the next 17 steps, it created six files, deleted nine, and took no action in the game itself.
Fable 5 reserved memory for information the game did not already expose. The player's money and current map position can be read from the screen every turn, so storing them creates redundancy. Strategy, plans, and tested rules exist only if Claude derives and records them.
Fable 5 used global.md as a dashboard for the current goal, a plan for gyms, and its own rules for memory use. A locations folder held route plans, while gameplay held learned mechanics.
After seven Poké Balls failed in a row against a Magikarp, for example, Claude wrote: "If 3+ balls fail in a row, VARY the timing by inserting extra wait presses between menu steps; the catch landed right after doing this."
With a much smaller directory, Fable 5 progressed farther than Sonnet 3.7. Opus 5.5 later used a similar approach: a small set of notes tracking the current goal and next steps, continually rewritten during play. It completed the game.
Explain the purpose of memory, not the procedure
The experiments suggest that Claude benefits from knowing what memory is for, but often performs worse under rigid rules about what to write. In CL-Bench, Anthropic simply told the model that a memory folder was available. That was enough for Opus 4.7 and Opus 5 to use it effectively.
They also tested specific rules, including "record only failures." Under that instruction, Opus 5 and Opus 4.7 lost much of the performance gain supplied by memory. Stronger models benefited more from freedom to judge salience, while fixed rules could weaken performance.
Older models benefited more from explicit steering. Sonnet 4.6 often failed to read its memory directory and did not test theories about incorrect answers. Prompting it to read memory before answering and explicitly test those theories nearly doubled its score, from 0.364 to 0.641. Sonnet 5 reads memory before answering in 9 of 10 cases, compared with less than half for Sonnet 4.6.
For frontier Claude models, Anthropic generally gives simple guidance: create a note when the user asks or when something is clearly worth remembering, and leave the judgment to Claude.
Dreaming can correct memory
Because Claude writes notes from an in-session judgment, a memory may be wrong from the start or drift as the environment changes. Later sessions can then read and trust the bad note.
Dreaming lets Claude test memory against the original transcript. A Pokémon run with Managed Agents provided a clear example.
Mt. Moon is a cave with an entrance on the west side of the map and an exit on the east. Near the entrance is a one-way ledge that drops the player onto the route they came from. Claude used the PokéCenter at the mountain entrance as a landmark, so whether it walked off the ledge depended on which side of the mountain it believed the building occupied.
At one point, Claude incorrectly recorded that the PokéCenter was on the east side. Leaving the building, it announced that Mt. Moon was behind it and marked the cave complete. A few actions later, it crossed the one-way ledge and landed on the previous route. The navigation tool did not show the drop, so Claude concluded it had overshot west and had been on the correct side all along.
Anthropic then ran dreaming over the memory folder containing the incorrect location. Claude checked the note against the transcript, found the discrepancy, and rewrote it. The transcript supplied a ground truth against which memory could be verified.
With the corrected note, Claude returned directly to Mt. Moon and eventually reached Cerulean City. In the uncorrected run, it fell from the ledge three times. After the third failure, it wrote that it would stop rather than keep looping. An automatic reply told it to continue. It returned to Pewter City to heal and restock, and the run ended without reaching Cerulean.
Dreaming can build new memory representations
Dreaming can also build representations that make memory easier to navigate. One example is a wiki: a collection of pages Claude writes and maintains, gathering knowledge about a subject and linking related notes. The links form a map that helps Claude locate memories as the collection grows.
Anthropic evaluated wikis on roughly 350,000 internal files from Stainless, a software company acquired in May, totaling about 420 million tokens. It created 25 questions about the corpus and supplied Claude with a search tool.
Claude was also instructed to build a wiki through dreaming. Across 128 sessions, Opus 5 agents explored files, wrote and corrected linked pages, merged duplicates, and checked claims against sources. Each session built on prior progress and used a shared log for coordination.
As dreaming grew from two sessions to 128, performance on the 25 questions rose from 13% to 48% of graded criteria.
Claude builds the wiki incrementally. After an initial version, later dreaming rounds add, edit, and prune it. Early on, Claude resembles a new employee with limited ability to answer from the wiki alone. Each round makes the knowledge map richer, more like an experienced employee's.
The wiki produced the largest benefit when Claude also had search. As the wiki grew, the combined system rose from 54% to 61%. Search alone was approximately 53%, and wiki alone peaked at 48%. Search plus the wiki also saved about 20,000 tokens per question.
Anthropic then examined which tasks benefited. It used the Harvey LAB benchmark and a collection of merger documents. Claude built a wiki, answered questions about the merger, and generated legal briefs, with search available as a comparison.
In a 24-question test, more than half required information from several documents and many required judgment or arithmetic. On those items, Claude scored 87% when consulting the wiki and 73% with search alone.
Other tasks gained little. In one LAB task, most criteria could be found by searching a single document. In another, the wiki grew larger than the source corpus. Like the mapmakers in Borges's "On Exactitude in Science," Claude produced a map as large as the territory and abstracted almost nothing.
Dreaming can promote notes to the top of the hierarchy
Dreaming can move selected notes to the top of the memory hierarchy, where the harness loads them proactively at the start of a session. Claude then does not have to search for the information or know that it should.
Context injection must be handled carefully. Injected memories consume tokens, and an incorrect note can enter every later session. Loading a note also does not guarantee adherence. Claude Code documentation warns that longer instruction files reduce compliance. The top layer therefore stays small, and part of dreaming's job is to move detail downward while leaving links behind.
Claude Code's auto memory follows the same constraint. Claude does not load all memory into every context window. It loads only the first 200 lines or 25 KB of MEMORY.md. That header acts as an index, showing what Claude knows and where to look.
Dreaming can focus memory on a goal
Memory should grow differently for different tasks. An assistant such as Claude Duet often benefits from memories organized around the person it helps, and dreaming can be tuned to build memory around that objective.
In a Harvey LAB acquisition simulation, Claude receives a set of contracts and generates a legal brief graded on its description of contract terms. The initial wiki instructions did not explain how the wiki should use those terms. Several agents wrote to one shared table at the same time and overwrote one another.
The resulting brief contained only 41 of 57 facts, or 72%. The shared table summarized terms poorly and lost others entirely when agents overwrote one another.
The instructions failed to communicate that the contract language was the most important part of the task. Claude then reflected on the failure, proposed instruction changes, and rebuilt the wiki. The loop led it to preserve contract terms faithfully and rewrite the workflow accordingly.
Each contract received its own page, maintained by one agent and quoting the terms word for word. The brief generated from the improved wiki met 100% of the criteria.
Dreaming can fill gaps left by individual sessions
When Claude writes notes, it sees only one session. Dreaming can search across many sessions for common patterns and repeated mistakes.
In the LAB wikis, Claude sometimes linked to pages that did not yet exist. A second dreaming pass closed many gaps. In one task, it found nine links from six pages to a missing escrow-agreement page, repointed them to the existing buyer-form-escrow-agreement page, and added three new pages, including an index.
Looking backward while working forward
Many design questions remain open. The first is when to create memory. An agent can write directly to a folder, file, or database during work, capturing salience at the source and making important details available immediately. Logging notes in the moment, however, pulls attention away from the main task. Dreaming moves memory creation into the background, but its output may not be immediately available.
The second is how to keep memory current. Claude can record an incorrect prediction, write a rule that was wrong from the start, or retain information that becomes irrelevant as the environment changes. Dreaming can correct these errors, but it requires compute. Continuously checking every memory may not be practical. A better strategy may focus on information likely to change or tune the cadence of dreaming to how often memories are accessed.
Third, transcript search is a reasonable foundation for memory. Combining representations such as wikis with search can work better on some tasks, but Claude must spend compute maintaining the representation and preventing errors or hallucinations from accumulating.
Even though Claude's judgment about salience has improved, no model can know exactly what future turns will require. Dreaming gives Claude a chance to look backward, use compute to organize memory, correct mistakes, and maintain representations that make the past accessible to future sessions. Memory systems will evolve with model capability, and many questions about their design remain unresolved.
The original article also links to a cookbook for getting started with dreaming and a knowledge-wiki example.
Source:Anthropichttps://www.anthropic.com/research/components-of-agent-memory


