This article offers a detailed look at memory design for AI agents, particularly Claude. Inspired by human memory, it explains how Claude learns from experience and consolidates it into long-term knowledge. It focuses on dreaming, a distinctive process for organizing memory, correcting errors, and creating new knowledge representations. Examples ranging from gameplay to complex document analysis explore the importance and potential development of agent memory systems.
1. Parallels Between Human and Agent Memory ✨
Life must be lived forward even though it can be understood only backward; designing agent memory presents a similar difficulty. Humans immediately encode experience with help from the hippocampus, but only some experience becomes long-term knowledge. Consolidation largely happens during sleep or quiet rest, when the hippocampus replays recent experience. Experience is gradually distilled and integrated into the neocortex, which stores most of the brain's knowledge.
Agent memory can work similarly. Agents record extensive information in task logs and transcripts. Researchers have proposed sleep-time compute: using idle time between interactions to reorganize existing context. Reflecting on logs can help an agent organize memory, correct mistakes, and generate new notes and representations. This process, often called dreaming, has proved useful for giving Claude effective memory.
Søren Kierkegaard wrote that life can be understood only backward, but must be lived forward. We faced a similar challenge when designing memory for AI agents.

2. Types of Claude Memory and Why They Matter 🧠
Agent memory means knowledge Claude acquires through experiences such as user interactions and assigned tasks, preserves across sessions, and stores as context it can read later. This differs from changes to model weights, in-context learning within one conversation, and compaction, which summarizes older conversation so work can continue in a new context window.
In the human brain, chemical signals around an experience can mark certain memories as important. Those memories are replayed more often during offline periods, stabilizing and integrating them into long-term memory. Similarly, Claude can tag important events in session logs when they occur, making them easier to find later, or write them into a store such as memory notes.
Claude records important events as memory notes. But how can it know in advance what matters?
2.1. Memory as a Prediction of the Future 🔮
Memory can itself be a prediction about the future. Recording a rule predicts that the pattern will matter again. Recording a verified fact predicts that a future agent will want to rely on it without checking it again. Claude has become much better at these predictions over time.
The CL-Bench 1.0 benchmark evaluated Claude's memory use. It asks Claude to retrieve database information and answer a series of questions. After each answer, it supplies the correct solution so Claude can write memories useful for future questions.
When Claude answers incorrectly, it can support a learning loop by recording the failure, developing a theory of what went wrong, testing it, and turning it into a rule for future answers. Different models developed their own loops with varying success.
- Claude Sonnet 4.6: Stopped at generating theories about wrong answers, leaving unverified guesses scattered through the memory directory.
- Claude Opus 4.7: Began consolidating notes into one reference document and marking which facts were verified or unverified.
- Claude Sonnet 5: Marked answers confirmed after the grader checked them, recording corrections when wrong.
- Claude Opus 5: Was the first to close the loop. Most entries included a rule, why it was true, answers to earlier questions, and clear warnings about discovered traps.

Like Opus 5, Claude Opus 5.5 and Claude Sonnet 5.5 closed the learning loop by using memory to capture verified rules for answering future questions. With memory, both scored almost identically to Opus 5.
2.2. Judging What Matters 🧐
Claude's ability to play Pokémon Red, a challenging game requiring complex long-term work, was used to test its judgment about what to store in memory. Each model received a folder of memory files it could read and write during play.
Comparing Claude Sonnet 3.7 and Claude Fable 5 revealed substantial differences in what they considered worth remembering.
- Sonnet 3.7: Assumed everything mattered and recorded indiscriminately, down to separate files for every battle, item, and NPC. It wrote 413 memory files across 225 folders and earned one badge.
- Fable 5: Wrote nine files in two folders plus a top-level
global.md, and earned four badges.
Sonnet 3.7's approach caused problems because Pokémon's game state continually changes. Detailed records became outdated, and Claude spent more time and resources searching memory than playing.
Fable 5 stored things the game did not explicitly reveal. Money and map position can be read from the screen each turn, so they need not be stored. Instead it saved strategies, plans, and tested rules—information that exists only because Claude discovered it and would disappear if not recorded.
It organized memory efficiently. global.md served as a dashboard containing current objectives, prewritten gym plans for earning badges, and the model's own memory-use rules. The locations folder held route-navigation plans; gameplay contained learned game strategies. Using a much smaller memory folder, Fable 5 progressed far beyond Sonnet 3.7. Opus 5.5 completed the game using a similar approach.

3. How to Instruct Claude to Write Memory ✍️
It proved useful to explain memory's purpose without prescribing how to use it. In CL-Bench, Claude was simply told that a memory folder was available. That general instruction alone enabled Opus 4.7 and Opus 5 to use memory effectively and improve performance substantially.
Tests also provided specific rules about what to record. Under an "only record errors" rule, for example, both Opus 5 and Opus 4.7 lost much of memory's performance benefit. For stronger models, freedom to judge importance worked better than predetermined rules, which could actually weaken performance.

Older models benefited more from instructions. Sonnet 4.6 often failed to read memory files or test theories about incorrect answers. Explicitly instructing it to read memory before answering and test its theories nearly doubled its benchmark score. Sonnet 5 did these things on its own.
For current Claude models, users provide simple guidance to create memory notes when requested or when something clearly merits remembering, leaving the judgment to Claude.
4. Dreaming: Correcting Memory and Creating Knowledge 💭
Claude writes notes based on what seems important within a session. Notes that were wrong originally, or became wrong as the environment changed, may later be read and trusted.
4.1. Correcting Memory Errors 🛠️
Dreaming gives Claude a way to test notes against original transcripts. Pokémon gameplay provided a positive example of correcting faulty memory.
Claude incorrectly recorded a Pokémon Center's location around the cave system Mt. Moon, trapping itself in repeated backtracking. Dreaming reviewed the memory folder against session transcripts, discovered the error, and corrected it. With corrected notes, Claude promptly returned to Mt. Moon and reached Cerulean City.
Dreaming lets Claude test notes against original transcripts.


Without corrected notes, Claude fell into the same trap three times, eventually recording that it would stop rather than keep looping and retreating to the preceding town with a Pokémon Center. Dreaming can prevent repeated mistakes caused by faulty memory and help it move in the right direction.
4.2. Building New Memory Representations: Wikis 📚
Dreaming can build new representations that help Claude navigate memory. One is a wiki: pages Claude writes and maintains that gather its knowledge of a topic and link to other notes. These links form a map for browsing and efficiently retrieving memories when needed.

Wiki-like representations help Claude navigate an ever-growing knowledge base. The researchers explored their benefits using 350,000 internal documents, approximately 420 million tokens. They created an evaluation set of 25 questions and asked Claude to explore the material, also instructing it to use dreaming to build a wiki from the files.
Across 128 sessions, scaling dreaming raised performance on the 25 questions from 13% to 48%. Claude built the wiki incrementally: initially like a new employee, then developing a richer knowledge map like an experienced employee as dreaming continued.

With search tools and the wiki together, Claude's overall score rose from 54% to 61% as the wiki grew. Search alone scored 53%; the wiki alone scored 48%. Combining them saved approximately 20,000 tokens per question.
4.3. Promoting Notes to the Top of the Memory Hierarchy ⬆️
Dreaming can promote notes to the top of the hierarchy, allowing the agent harness to preload them into Claude's context at every session's start, eliminating the need to search for them.

Injecting memory into new sessions requires care. It consumes valuable tokens and can propagate incorrect notes into every session. Loading a note also does not guarantee Claude follows it. The top layer should therefore remain relatively small; much dreaming work maintains that by moving details down the hierarchy and leaving links behind.
4.4. Focusing Memory on Particular Goals 🎯
Dreaming can influence how memory grows. An assistant such as Claude Duet benefits from memory organized around the person it assists. Dreaming can be tuned to build memory supporting particular objectives.
In one LAB benchmark task, Claude received a merger-and-acquisition scenario and had to write a legal report on contractual terms. Initial wiki-building instructions did not explain how the wiki would be used. Multiple agents wrote terms into a shared table simultaneously, producing a wiki missing important facts.

A loop asked Claude to reflect on failures, propose instruction changes, and rebuild the wiki. Recognizing the importance of faithfully preserving contract terms, it rewrote the wiki instructions. Each contract received its own page written by a single agent, quoting terms verbatim rather than summarizing them. Reports generated with the improved wiki could meet 100% of the criteria.
4.5. Filling Gaps Between Sessions 🩹
When writing notes, Claude sees only one session's context. Dreaming can search across sessions for common patterns or shared mistakes.
While building the LAB wiki (see Figure 14), Claude sometimes linked to pages not yet created. A second dreaming pass filled most gaps. In one task it found nine links to missing pages and redirected them to existing pages for the same documents. It also added three new pages, including an index, to improve the wiki.

5. Looking Back and Ahead: Memory-System Challenges 🧐
Many challenges remain:
- When to create memories: Claude can write to a memory store during work, but live note-taking distracts it from the main task. Dreaming moves creation into the background, though the resulting memories may not be immediately available.
- Keeping memories current: Claude can make faulty predictions or record incorrect rules from the outset. Environmental changes can make memories drift and lose relevance. Dreaming can fix errors but consumes compute. Continuously checking every memory may be impractical; focusing dreaming on changeable information or carefully tuning its cadence may matter instead.
- Using transcript search: Treating transcript search as the foundation of Claude memory is reasonable. Combining search with wiki-like representations can work well, but maintaining those representations and preventing accumulated errors or hallucinations requires compute.
Claude's judgment of importance has improved, but no model can know exactly what will happen. Dreaming provides an opportunity to look backward, spending compute to organize memory, correct mistakes, and maintain representations that future sessions can access more easily. Memory systems will evolve with Claude's capabilities, and much remains to learn about designing them.
Closing Thoughts 👋
Claude's memory system goes beyond storing information: it is a complex structure that draws on human memory mechanisms to learn and develop. Through dreaming, Claude has developed ways to reflect on experience, correct misinformation, organize knowledge, and express it in new forms. Cases such as Pokémon gameplay and legal-document analysis illustrate flexible, effective memory use. As these systems become more sophisticated, we may encounter increasingly intelligent and reliable agents. 🚀
