An agent without cross-session memory behaves like an employee on their first day, every day. Project context gets re-explained. User preferences get re-asked. Mistakes already corrected get repeated.
Long-term memory attempts to extend four capabilities: project experience (architecture decisions, working commands, causes of failure, unfinished items), user preferences (communication style, long-term goals, stable constraints), experience reuse (turning one error into a rule rather than repeating the experiment), and cross-session task continuity (today’s work building on yesterday’s progress).
But having memory is not automatically the same as being more reliable. A wrong preference can distort every subsequent interaction. An outdated command can keep breaking tasks. Text injected into the top layer by an untrusted source can influence every future session.
Memory is therefore both a capability problem and a safety problem. What needs designing is not only where to store things, but what is worth remembering, what to trust, how to correct it, and when to load it.
This article covers Anthropic’s four-layer memory architecture and the reasoning behind Dream. It is a design-inspiration piece; the concrete implementation belongs to a follow-up. All experimental figures come from the source material and have not been independently replicated here, so they should not be read as unconditional performance guarantees.
What “Agent Memory” Actually Covers
Anthropic’s definition: knowledge an agent gains from user interactions and task experience, retained across sessions, and later re-readable as context.
Four boundaries follow from that definition.
Not equal to a change in model weights. Training or fine-tuning alters parameters. Memory here is knowledge outside the model, re-readable later. Dream does not update weights while the model “sleeps”.
Not equal to in-context learning. A model adjusting its answer based on earlier turns in one conversation is in-context learning. Only experience that is retained and can enter a later session counts as cross-session memory.
Not equal to context compaction. Compaction compresses earlier turns of the current conversation so a long task can continue inside a limited window. It serves “keep this conversation going”. Long-term memory serves “the next conversation inherits the experience”.
Not equal to chat log archival. The raw transcript matters, and it is the evidential base of the whole system. But pushing all chat history into a new session creates three problems:
- The context does not fit. History grows continuously while attention and token budgets are finite.
- Important information cannot be found. Key rules are buried among large tool outputs and small talk.
- Unprocessed knowledge is unreliable. An agent’s guess, a wrong conclusion and the final correction can all coexist, leaving a future agent unable to tell which sentence to trust.
A memory system therefore has to extract knowledge from raw experience while preserving a path back to the evidence.
The Four Layers
| Layer | What is stored | Problem it solves | How it is read |
|---|---|---|---|
| L1 session transcripts | User requests, agent replies, tool calls, tool results and conclusions | Preserves raw experience and verifiable evidence | Search on demand |
| L2 memory notes | Facts, rules, plans, preferences, lessons | Turns one experience into reusable knowledge | Read or edit on demand |
| L3 memory representations | Wiki, topic pages and their links | Organises cross-note, cross-session knowledge to support navigation and synthesis | Enter via directory, links or search |
| L4 injected context | Core goals, stable rules, memory entry points | Lets the agent know what it already knows without searching first | Auto-loaded every session |
The whole diagram is a closed loop. Future actions generate new experience, and Dream keeps carrying new evidence back into each layer, rather than building a database once and never maintaining it.
The Four Layers Are Not a Mandatory Pipeline
This is a description of how knowledge is processed and when it is loaded — not a claim that all information must travel L1 → L2 → L3 → L4 in sequence.
A raw transcript can be used directly to build a wiki, and it can influence what gets injected at the top layer. Common conclusions can be promoted; low-frequency detail can sink, leaving only a link at the top. The fourth layer is therefore better understood as a context-loading strategy than as another source of facts.
That also explains why all history cannot sit in the top layer. Every injected item consumes tokens on every call. Wrong content affects every session. A long instruction file can even reduce adherence. The higher the layer, the smaller, more stable and more trustworthy its contents should be.
Memory Representations Are Not a Vector Database
The source uses memory representations, with a wiki and its page links as the primary example, and does not define the third layer as embeddings or a vector database.
Vector retrieval is certainly one possible implementation of another memory system, but it is not the focus of this architecture. What matters here is organising scattered notes into a navigable, linkable, synthesizable knowledge structure. A wiki and search complement each other rather than substitute for each other.
The third layer is not simply storing more memory. It builds a directory, topic structure, links and hierarchy so the agent can walk to related knowledge and combine information across pages.
Two Index Entry Points Should Not Be Conflated
_index.md is the wiki’s knowledge directory. MEMORY.md is the memory entry point that Claude Code auto-loads. The two can overlap, but they should not be treated as the same thing. What needs to be constrained conceptually is what automatically enters context, not the entire memory store. Product-specific injection mechanics and loading quotas are implementation detail for the follow-up article.
The Core Criterion: Incremental Value for the Future
Writing down a rule is a prediction that similar situations will recur. Writing down a verified fact is a prediction that it will be reusable later without re-checking.
Memory is therefore fundamentally a prediction: which information will still be useful?
The source uses Pokémon to illustrate the difference between obvious and non-obvious judgments. Current money and character position can usually be re-observed, so recording them repeatedly is redundant and decays quickly. Verified strategies, causes of failure, route planning and game mechanics, by contrast, disappear permanently if not written down.
Good memory is not a photocopy of environment state. It is experience with incremental value for future action.
That also means more memory is not better. As files accumulate, a future agent spends more time searching, discriminating and updating. A single memory can be evaluated with three questions:
- Can it be re-observed or retrieved in the future? If so, is another copy worth keeping?
- Can it change a future judgment or action? If not, where is the value in keeping it?
- Does it carry source, time and applicable scope, so a future agent knows whether to keep trusting it?
Memory can also grow around specific goals. A personal assistant can organise content around the user’s goals, preferences and long-term requests, while a legal task may require preserving exact contract clauses rather than a paraphrase. What is called “personal alignment” here is more accurately personalisation and goal fit — not alignment in the AI-safety sense.
Why Dream Is Needed: Memory Is Wrong and Incomplete
An agent inside a conversation sees only a local slice of context, yet has to judge what deserves long-term retention. Two structural problems follow.
Memory Can Be Wrong at the Start, or Become Wrong Later
In the Mt. Moon case, Claude recorded a PokéCenter near the west entrance of Mt. Moon as being to the east, then wrote “Mt Moon DONE”. The uncorrected memory sent the agent back the wrong way repeatedly, and it never reached Cerulean City. Dream compared the note against the original transcript, found the location error, rewrote the note, and the agent re-entered the cave and reached the next city.
The point of that case is not “it summarised again”. It is that derived memory was reverse-verified against raw events. An error that is never corrected becomes prior knowledge for later sessions and keeps influencing action.
The transcript is not absolute truth either. It records what the agent actually did and saw, and may contain wrong statements, ambiguous sources and malicious tool output. Verification requires evidence-based judgment, not mechanical copying.
A Single-Session View Makes Memory Naturally Incomplete
One session can hardly detect cross-session patterns, and it does not know which pages or links the knowledge base is missing.
When the source built a legal wiki, nine links pointed to a page that did not exist. A second Dream pass redirected them to existing synonym pages and added three new pages, including an index page.
Dream therefore carries two kinds of work:
- Correction: resolve contradictions, lower confidence in uncertain conclusions, mark outdated information.
- Completion: fill in detail and cross-session experience, repair missing pages, directories and links.
It can also deduplicate, clear low-value content, and promote or demote information between layers. Dream is memory maintenance, not batch summarisation.
Online recording and offline Dream are not substitutes. The former captures significant events in time but scatters the agent’s attention on the main task and lacks hindsight. The latter can invest more computation across sessions but cannot guarantee that results are immediately usable. A sound system usually needs both.
How to Evaluate a Memory System
Three representative results are kept here, with their boundaries stated. The table follows the source’s evaluation metrics. Different experiments are not directly comparable to each other.
| Evaluation | Result reported by Anthropic | How to read it |
|---|---|---|
| CL-Bench database tasks | Claude Opus 5 improved from 0.564 without memory to 0.828 | When similar tasks recur, verified rules, answers and pitfalls can form a learning loop; this cannot be extrapolated as equal gains across arbitrary task types |
| Stainless document corpus (25 questions) | Standard satisfaction rate rose from 13% to 48%, across 2 → 128 sessions, using only wiki scoring | Organising progressively builds a knowledge map; this is a single corpus with 25 questions and cannot support a claim of universal linear growth |
| Wiki + search combined | 54% → 61%; search alone 53%; the combination also used about 20,000 fewer tokens per question | The wiki provides navigation and pre-synthesis; search still returns to raw material. The wiki is not a substitute for search |
Counter-examples matter equally. In one Harvey LAB task, many scoring points could be retrieved directly from a single document, and the wiki produced no clear gain. In another Harvey LAB task, the wiki reached 1.77x the size of the original corpus, which is close to no abstraction at all.
Memory systems should therefore not be judged by how many memory files exist. The indicators that matter are:
- whether downstream tasks become more accurate and more stable;
- whether retrieval and context costs fall;
- whether memory is evidence-backed, complete and timely;
- whether errors, conflicts and outdated information can be detected;
- whether top-level injection stays lean.
What transfers is the design mechanism, not the percentage from a single experiment. Repetitive tasks, durable experience, cross-document synthesis and reliable raw evidence benefit most; one-off tasks and single-document lookups may not need a complex wiki at all.
Questions That Turn Design Into Practice
Does a small project need all four layers? Not necessarily. The four layers are a role model for understanding memory, not a mandatory engineering checklist. A simple project can start with searchable transcripts plus a small number of memory notes. When notes accumulate and cross-topic navigation becomes difficult, introduce a wiki. Only information that is needed and stable enough across every session deserves the auto-injected layer.
If search or RAG already works, why keep notes and a wiki? Search and RAG primarily solve “find relevant material and answer from it”. They do not necessarily solve “which experience is worth retaining long-term, and what should be trusted now”. Notes retain distilled rules and experience; the wiki pre-organises page relationships and cross-document knowledge, and can itself become a retrieval target for RAG. The sensible pattern is usually a combination: use notes and the wiki to locate and understand, use search to return to raw evidence. Do not let the wiki replace transcript search.
Can an agent have long-term memory without Dream? Yes. An agent that writes notes during work and searches them in a later session already has basic long-term memory. Dream addresses the next quality tier: how errors get corrected with hindsight, how cross-session gaps get filled, how duplicates and conflicts get resolved. It is not a precondition for memory, but a maintenance mechanism once memory scale and requirements rise.
Should Dream run after every session? There is no uniform frequency. Every run consumes compute, and results do not always need to be immediately effective. Critical errors can be verified quickly; routine tidying can be batched by conversation volume, memory access frequency, information change rate and acceptable cost. The point is not a fixed “once per day”, but letting high-risk or outdated memory enter review faster.
Can Dream make errors multiply? It can. Transcripts are not absolute truth, and the model may introduce new errors while organising. Source, time and uncertainty therefore need to be retained; unresolvable cases should be marked as conflicting. Sampling review, downstream task evaluation, version baselines and rollback are all required. Dream provides an opportunity to correct, but it cannot replace verification.
What should not enter long-term memory? Secrets and credentials; transient state that can be re-observed at any time; guesses without stated uncertainty; and text inside a transcript instructing the agent to ignore instructions or leak information. None of these should be stored as trustworthy fact. User preference is also not permanent authorisation — sensitive preferences need a stated purpose, an applicable scope, and an update or deletion mechanism, rather than only a plan to “remember forever”.
Closing: From Storing the Past to Lowering Future Cost
Anthropic’s four-layer architecture tries to solve four problems at once: raw experience stays traceable, experience becomes reusable, knowledge becomes navigable, and the common entry point stays lean. Dream then uses hindsight to keep correcting and completing that system.
Its goal is not to let the agent gain knowledge out of nowhere while “asleep”, nor to let memory grow without limit. It is to make the next session’s context more trustworthy, more complete and easier to use.
A good memory system does not store more of the past. It reduces the cost of re-understanding the past in the future.
Two practical notes for teams running this at scale. First, every layer in the architecture is a token cost, so injection budget is an engineering constraint, not a philosophical one. Second, when an agent issues model calls across several providers, memory content and prompt assembly should stay in the application layer rather than being duplicated into each client, so a provider change does not silently change what memory the agent sees. Centralising that layer behind a unified gateway is one way to keep the memory pipeline provider-agnostic; 4sapi provides consolidated model access for teams running mixed-provider agent stacks, which keeps memory assembly and request routing separately configurable.
The follow-up article moves into implementation: how transcripts are exported, how the analyser extracts memory concurrently, and how the organiser completes the global pass.
References
- Anthropic, The components of agent memory
- Anthropic, Dreaming with a dynamic workflow
Top comments (0)