source · sources/Anthropic — The Components of Agent Memory.md

Anthropic — The Components of Agent Memoryauto-ingested

status: active · created 2026-11-08 · 1 source · #agents #agent-memory #context-engineering #dreaming #llm-wiki #anthropic #auto-ingested

Anthropic Engineering post on how Claude decides what to remember between sessions, and how offline "dreaming" corrects, restructures and prunes that memory. It includes an evaluation of agent-maintained wikis, the same pattern this wiki runs on. Subscribed-feed capture (Anthropic Research), auto-fetched and auto-ingested 2026-11-08; awaiting human review.

Summary

Framing. Kierkegaard: life is understood backward but lived forward. An agent must decide what is worth remembering before it knows what comes next. Humans handle this with a division of labour: the hippocampus encodes quickly in the moment, and offline replay (sleep, rest) consolidates only some experiences into neocortical knowledge. Agents can copy that split. They write notes in-session, then reflect over logs and transcripts offline. This offline pass is called dreaming, building on Letta/UC Berkeley's "sleep-time compute" idea.

Scope. "Agent memory" means knowledge gained from experience and kept between sessions as readable context. It excludes weight changes, in-context learning and compaction (summaries that replace older turns).

Memory is a prediction. Writing a rule predicts that the pattern will matter again. Writing a verified fact predicts that a future session will want to rely on it without re-checking.

Key claims and data

1. Models have learned to close the learning loop (CL-Bench 1.0 database task). Each question ran in a fresh session with only a persistent memory directory.

  • Sonnet 4.6: generated theories about wrong answers but left them untested. The result was scattered files of guesses.
  • Opus 4.7: consolidated notes into one reference document and marked facts as checked or unconfirmed.
  • Sonnet 5: marked answers confirmed after grading and wrote corrections.
  • Opus 5 first closed the loop. Its entries held a rule, how it knew the rule was true, earlier answers, and warnings about traps. Opus 5.5 and Sonnet 5.5 did the same, scoring about the same as Opus 5 with memory.

2. Salience judgment beats hoarding (Pokémon Red, ~10,000 steps).

  • Sonnet 3.7 wrote 413 files in 225 folders (one per battle, item and NPC) and earned 1 badge. The game state kept changing, so the archive kept going stale. At one point it spent 17 steps creating 6 files and deleting 9, taking no game actions.
  • Fable 5 wrote 9 files in 2 folders plus global.md and earned 4 badges. global.md was a dashboard (current goal, gym plan, its own rules for memory). It stored only what the game doesn't show: strategy, plans and tested rules, which "exist only if Claude works them out." It did not store money or position, which can be read off the screen. Example rule: "If 3+ balls fail in a row, VARY the timing."
  • Opus 5.5 kept a small, constantly rewritten goal/next-steps folder and beat the game.

3. Say what memory is for, not how to use it.

  • Just saying "a memory folder is available" was enough for Opus 4.7 and Opus 5 to get a clear boost.
  • A fixed rule ("record only failures") removed much of that boost for both. "For stronger models, giving them freedom to judge salience was more effective than setting fixed rules in advance."
  • Steering helped older models most. Telling Sonnet 4.6 to read memory before answering and to test its theories nearly doubled its score. Sonnet 5 read memory unprompted 9 times in 10; Sonnet 4.6 did so less than half the time.

4. Dreaming corrects memory. A note can be wrong from the start or drift out of date, and later sessions still trust it. In Pokémon, Claude wrongly noted that the PokéCenter was east of Mt. Moon, wrote "Mt Moon DONE," fell off a one-way ledge, and explained it away ("I overshot far west"). Dreaming checked the note against the session transcript as ground truth and rewrote it. With the fix, Claude went back into the cave and reached Cerulean City. Without it, Claude fell off the ledge 3 times, tried to quit, and never got past the mountain.

5. Dreaming builds representations: the wiki (citing Karpathy's LLM-wiki gist).

  • Stainless corpus (~350k files, ~420M tokens, 25 questions). Over 128 sessions, Opus 5 agents explored files, wrote or corrected linked pages, merged duplicates and checked claims against sources, coordinating through a shared log. Score rose from 13% to 48% of graded criteria as dreaming went from 2 to 128 sessions. The early wiki was like a new employee's knowledge, the late one like a seasoned employee's.
  • Wiki and search together did best: search + wiki rose from 54% to 61% as the wiki grew, against 53% for search alone and 48% for wiki alone. The combination also saved about 20k tokens per question.
  • Merger questions (more than half needing several documents plus judgment or math): 87% with the wiki against 73% with search alone.
  • Where it didn't help: on a LAB task whose criteria each lived in a single document, there was no clear gain. On another task, the wiki grew larger than the raw documents. Like Borges's 1:1 map, it "effectively abstracted nothing."

6. Dreaming promotes notes up the hierarchy. The harness can pre-load a small top layer into every session. This must be done carefully: injected notes cost tokens, a wrong note is carried into every session, and "longer instruction files reduce adherence." Much of dreaming's work is keeping the top layer small by pushing details down and leaving links behind. Claude Code's auto memory loads only the first 200 lines / 25 KB of MEMORY.md, which works as an index.

7. Dreaming can be aimed at a goal. On a LAB acquisition task, several agents writing to one shared contract-terms table overwrote each other and summarized badly. Only 41 of 57 graded facts survived (72%). A reflect → revise instructions → rebuild loop led to one agent per contract, quoting terms word for word, and 57 of 57 survived (100%).

8. Dreaming fills cross-session gaps. A single session sees only its own context. A second pass found 9 links to a missing page and repointed them to an existing page for the same document. It also added 3 pages, including an index.

Open questions the post names:

  • When to write memory: writing in-session is immediate but distracts from the task, while dreaming is backgrounded but its output isn't available at once.
  • How to keep memory current: checking every note isn't practical, so dreaming could focus on volatile information or set its cadence by how often notes are accessed.
  • Whether transcript search should be the foundation, with representations on top. Representations cost compute to maintain and can accumulate errors or hallucinations.

Connections

Source

The wiki is the source. This door reads it at build time and never writes to it.