The components of agent memory

An Anthropic engineering post by Lance Martin that sorts agent memory into layers (transcripts, notes Claude writes, representations such as wikis, and context injected into every session) and reports small internal tests: on a CL-Bench database task newer Claude models gained more from a memory folder, a rule to record only failures cut Opus 5's gain, and offline "dreaming" passes corrected a wrong note in Pokémon and built wikis that raised scores on some document tasks but not others.

Lance Martin (Anthropic) · 2026-11-06 · original

An agent that works across many sessions has to decide, during a session, what a later session will need. This post asks how Claude should make that decision, and what can be done afterwards, when the record of the session is available, to fix the decisions it got wrong. It frames the second step as "dreaming": an offline pass in which Claude reads its own transcripts and memory and reorganizes them, by analogy with the consolidation of memories during sleep.

The post was published on anthropic.com under the Engineering label on 6 November 2026, written by Lance Martin. It is the version of record; there is no companion paper. Its numbers come from 15 figures, numbered in the text (the images and captions print no figure numbers), several of which print values and run counts that the text omits, and this note cites them by figure number. The evaluations are internal and small, mostly single runs or a handful of runs, and the post presents them as explorations, not as a benchmark study. The post ends with links to two cookbooks, one for dreaming with Claude Managed Agents and one for knowledge wikis.

Terms used in this note

  • Agent memory. The post's definition: knowledge Claude gains from experience (interactions with users, assigned tasks) and keeps between sessions as context it can read later. It excludes weight changes, in-context learning within one conversation, and compaction (summaries that replace older turns so work can continue in a new context window).
  • Memory hierarchy. The post's four layers, from bottom to top (Figure 1): transcripts (a searchable event log), memory notes written by Claude, memory representations such as wikis, and injected context loaded at the start of every session.
  • Dreaming. An offline pass over logs and memory that can correct notes, create new ones, build representations, or decide what is injected. The post credits the related idea of sleep-time compute to researchers at Letta and UC Berkeley, and notes that the term "dreaming" is used elsewhere, including in Anthropic's Managed Agents documentation.
  • Stateless baseline. The same task with no memory carried between sessions.

What the post does

The post walks up the memory hierarchy and illustrates each layer with a test.

  • CL-Bench database task. A task from Continual Learning Bench 1.0, an external benchmark of memory use on long-horizon tasks. Claude answers a series of questions by looking up a database, is told the correct answer after each, and may write memory. Each question starts a fresh session in Claude Managed Agents, with only a persistent memory directory carried over. The prompt simply said a memory folder was available. Six models were compared with and without memory over 30 questions (Figure 3).
  • Pokémon Red. Each model got a folder of memory files to read and write while playing. The post compares the folders of one run each of Claude Sonnet 3.7 and Claude Fable 5 at about step 10,000 (Figure 4), and, separately, one episode at Mt. Moon with and without dreaming (Figures 7 and 8). The model used in the Mt. Moon episode is not named.
  • Wikis from a document corpus. About 350,000 internal files (roughly 420M tokens) from Stainless, a company Anthropic acquired in May, with 25 evaluation questions. Opus 5 agents, coordinated through a shared log over 2 to 128 dreaming sessions, explored the files, wrote and corrected linked wiki pages, merged duplicates and checked claims against sources (Figure 10).
  • Legal documents. Harvey's LAB benchmark, which asks for a legal brief from a set of documents and grades it against criteria, plus 24 questions about a merger. Claude answered from a wiki it had built or from direct file search (Figures 11, 12, 14 and 15).

Results are reported as mean reward on CL-Bench and as the share of graded criteria met on the document tasks; the 25-question set was written by the authors. The post does not describe how any of these were graded or say whether the grading was checked against human judgment, and it gives no run counts for the document results.

What it finds

Newer models gain more from memory

On the CL-Bench task (Figure 3, mean reward, stateless baseline then with memory):

Model Baseline With memory
Opus 5.5 0.655 0.838
Sonnet 5.5 0.644 0.833
Opus 5 0.564 0.828
Opus 4.7 0.383 0.700
Sonnet 5 0.306 0.610
Sonnet 4.6 0.330 0.364

Figure 5 gives run counts for some of these: 16 runs for Opus 5 with memory, 3 for Opus 4.7 with memory, and 3 each for the Sonnet 4.6 conditions. Figure 3 gives no run counts or error bars for the others. The text describes how the memory folders differed: Sonnet 4.6 left scattered files of untested guesses; Opus 4.7 kept one reference document marking facts as checked or unconfirmed; Sonnet 5 marked answers confirmed after grading and wrote corrections; Opus 5 was "the first of these models to close the loop", writing rules with how it knew them and warnings about traps. Opus 5.5 and Sonnet 5.5 also closed the loop and scored about the same as Opus 5 with memory, from higher baselines.

What gets written to memory

At about step 10,000 of Pokémon Red (Figure 4, step 9,989), Sonnet 3.7 had written 413 files and 977,930 characters across 225 folders and earned one badge; Fable 5 had 10 files (nine in two folders plus a top-level global.md) and 43,406 characters, and earned four badges. This is one run per model. The post's reading is that Sonnet 3.7 stored facts the screen already shows, which went out of date and cost time to search; near step 10,000 it spent 17 steps creating six files and deleting nine with no game actions. Fable 5 stored strategy, plans and tested rules, which exist only if the agent writes them down. The post adds that Opus 5.5 kept a small folder of goals and next steps and beat the game, without giving its numbers.

Telling Claude what to remember

  • A fixed rule cut the gain. Telling models to "record only failures" changed their gain from memory by −0.234 for Opus 5 (3 runs), −0.150 for Opus 4.7 (3 runs) and −0.020 for Sonnet 4.6 (1 run), with standard errors drawn as error bars (Figure 5, right). The text says both Opus models "lost much of the performance boost that memory gave them". Set against their gains in Figure 3 (0.264 for Opus 5 and 0.317 for Opus 4.7; our arithmetic, and Figure 3 may rest on other runs), that is about nine tenths of Opus 5's gain and about half of Opus 4.7's. The post's conclusion is that for stronger models, freedom to judge salience worked better than fixed rules.
  • Specific prompting helped an older model. Prompting Sonnet 4.6 to read its memory before answering and to test its theories raised its mean reward from 0.330 (baseline) and 0.364 (memory) to 0.641, 3 runs each, with a standard deviation bar on the last condition spanning roughly 0.50 to 0.78 (Figure 5, left; the interval is read from the figure). The text calls this "nearly doubled"; 0.641 is 1.94 times the stateless baseline and 1.76 times the memory condition (our arithmetic). The post reports that Sonnet 5 read its memory before answering 9 times out of 10 without being told, and Sonnet 4.6 less than half the time.

Dreaming corrected a wrong note

In one Pokémon episode Claude wrote, wrongly, that the PokéCenter near Mt. Moon was on the east side, then walked off a one-way ledge. Running dreaming on that memory folder, Claude checked the note against the session transcript and rewrote it; with the corrected note, Claude went back into the cave and reached Cerulean City at action 1,935 (Figure 8). With the uncorrected note, it fell off the ledge three times, wrote "I'm going to stop rather than keep looping," was told by the harness's automatic reply to continue, and backtracked to Pewter City; a run with no memory also did not reach Cerulean within 3,000 actions (Figure 8). The episode was played through Claude Managed Agents with a mounted memory directory. Figure 8 plots one run per condition, with progress measured as estimated tiles traversed; the post reports no repeats.

Wikis helped where answers span documents

  • Stainless corpus (Figure 10). As dreaming grew from 2 to 128 sessions (a budget of 1M tokens per session, the figure notes, not measured spend), answering from the wiki alone rose from 13% to 48% of graded criteria, and answering with wiki plus search rose from 54% to 61%, against 53% for search alone. Wiki plus search also saved about 20,000 tokens per question. The example wiki grew from 103 pages and 766 links to 222 pages and 12,893 links.
  • Merger questions (Figure 11, left). On the items of the 24-question set that needed several documents, judgment or arithmetic (the red and orange lines, 16 of the 24 by our count from the figure), Claude scored 87% with the wiki and 73% with search alone. The figure notes that these class labels are "model-assigned".
  • No clear gain, and over-building. On a LAB task whose criteria could mostly be met from one document by text search, the wiki showed no clear gain (Figure 11, right). On another, the wiki reached 68 pages, 255 links and 203 KB from a 115 KB, 10-document corpus, 1.77 times the corpus (Figure 12); the post compares it to the map in Borges's "On Exactitude in Science".

Instructions for building memory mattered

On a LAB acquisition task, basic wiki-building instructions led several agents to write to one shared page of contract terms, overwriting each other; a brief from that wiki included 41 of the 57 graded facts (72%). The authors then ran a loop in which Claude reflected on failures, proposed an instruction change and rebuilt the wiki; the revised instructions gave each contract its own page, written by one agent and quoting terms word for word, and with that wiki "100% of the criteria could be met". The text counts facts in the brief; Figure 14 labels the same numbers as graded facts that "survived" in the wiki (41 of 57, then 57 of 57). The change altered both the wording and the division of work among agents, so the two cannot be separated. A second dreaming pass on another wiki repointed nine links aimed at a missing page and added three pages, including an index, taking it from 38 entries and 225 links to 41 entries and 278 links (Figure 15).

The instructions used

Several results in the post concern the wording of instructions to the agent, Only two are on/off comparisons with run counts, both on CL-Bench: the fixed rule and the Sonnet 4.6 refined instruction. The wiki-instruction change is a single before and after.

  • General guidance. On CL-Bench the models were "simply told" a memory folder was available. The post's stated practice for frontier models is to give "simple guidance to create memory notes when a person asks them to or when something is clearly worth remembering" and leave the judgment to Claude.
  • A fixed rule. "Record only failures", one rule per test, compared against the same model's gain without it (Figure 5, right). The other rules tested are not listed.
  • Refined instruction. For Sonnet 4.6, an instruction to read memory before answering and to test theories explicitly (Figure 5, left). Its exact text is not given, and its two parts were not tested separately.
  • Instructions for wiki building. Rewritten by Claude itself after reflecting on graded failures; the post gives the resulting design (one page per contract, verbatim terms) but not the instruction text.
  • Injected context. The post cites Claude Code's documentation as warning that longer instruction files reduce adherence, and describes Claude Code's auto memory as loading only the first 200 lines or 25 KB of MEMORY.md as an index. These are the documentation's statements, not tested in the post.

Limitations and open questions

  • Small samples. Most comparisons are one run (Pokémon, the Mt. Moon episode, the document tasks) or three (CL-Bench conditions in Figure 5). Run counts are missing for most of Figure 3, and the document results give none.
  • Graders unstated. The post does not describe how CL-Bench, LAB or the 25-question set were graded, or whether the graders were validated.
  • Confounds in model comparisons. The Pokémon comparison sets a 2025 model against a 2026 model, so harness or tool differences cannot be separated from the model; the post does not say whether the harness was the same.
  • Selected examples. The Mt. Moon episode is described as "a positive example"; the post does not say how often dreaming corrected or introduced errors in other runs.
  • Open questions the post names. When to write memory (in the moment, at a cost to the main task, or later through dreaming, at a delay); how to keep memory current without paying to check everything; and whether transcript search should be the foundation, with representations maintained at a compute cost.

Research questions

  1. How often does dreaming introduce errors? Running dreaming over many memory folders with known errors and known-correct notes, and counting corrections and new errors, would give a rate rather than an example.
  2. Is the "record only failures" effect specific to that rule? Testing several fixed rules of different strictness, with run counts per model, would show whether fixed rules in general reduce the gain or only this one.
  3. Does the CL-Bench ranking hold on other memory tasks? Repeating the six-model comparison on further CL-Bench tasks would show whether "closing the loop" generalizes.
  4. When is a wiki worth its cost? Measuring, across many corpora, how the gain from a wiki varies with the share of questions needing several documents would test the post's explanation of Figure 11.
  5. What limits wiki size usefully? Comparing wikis built with and without a size or abstraction instruction on the task where the wiki outgrew its corpus would show whether instructions can prevent over-building.
  6. Does injected context lose adherence with length for memory as it does for instructions? Varying the size of an injected memory index and measuring whether Claude acts on its entries would test the documentation's warning for this use.

How it connects

References