Skip to content
The AI Agent Factory

31.3 Memory in four layers

Approved by
Panaversity ·
10 min read

In everyday life. A lawyer's office keeps everything. The recordings of every client meeting sit in a basement archive. Each lawyer keeps notebooks. The office has a filing system, with an index of cases. And on the reception desk is one laminated page of rules everyone must see each morning. Nobody reads the archive every day. Everybody reads the laminated page.

What you will learn. The four layers of a worker's memory, what goes in each, and why the top layer must stay small. You practise it in Lab 31, Task 1.

Why it matters. A memory that loads everything into every run is slow and costly, and its important rules drown in detail. A memory that loads nothing is useless.

What are the four layers?

Anthropic's engineering post on agent memory describes memory as layers that narrow as they rise: everything is logged, and little is loaded into every run.1 In this chapter's files:

LayerWhat it holdsBrightline's filesLoaded
4. Injected contextThe few rules every run must seeinstructions.md and index.mdEvery run
3. Memory representationsOrganized pages, linked from the indexnotes/ pages, such as notes/cedar-ridge/credit-memos.mdWhen the index points to them
2. Memory notesWhat a run writes while it worksscratch/<run>/notes.mdBy the next dream
1. TranscriptsEvery session: messages, tool calls and resultsThe platform's session eventsBy the dream only

Four stacked layers, widest at the base. Bottom: transcripts, every session in full. Then memory notes, written during runs. Then memory representations, the notes pages and their index. Top, narrowest: injected context, loaded into every run. An arrow on the right, labeled dreaming, points upward from transcripts to the layers above. Below: everything is kept; little is loaded every time.

Figure 31.4. Memory narrows as it rises. Dreaming moves what matters upward, and keeps the top small.

How did memory get here?

In four steps, over about a year, each the simple thing that worked. Mukta traced the path in her talk:2

StepWhat it isWhat it taught
1. CLAUDE.mdA Markdown file loaded at the start of every Claude Code session"Unreasonably effective" at steering. People and the worker can both read and write it. It breaks down as it grows long
2. Memory toolsThe worker decides when to read, write and update memory, in bandLetting the worker decide works well. Later systems cared less about the exact shape of the tools
3. SkillsKnow-how behind a short description; the body loads only when relevantLoading only what is needed solves the ever-growing context. But a person still decides what deserves a skill
4. File-system memoryMemory as a folder of Markdown, searched with ordinary tools such as grepMemory can grow large while the worker searches for what matters. Workers already use these tools well

Her picture for step 3 is a bookshelf. You scan the titles, and pull down the French dictionary only when someone speaks French. You do not carry seven years of French classes in your head. This is called progressive disclosure: a short description first, the full text only when needed.

The talk ends with three principles. Markdown is a good format for memory. Let memory grow large, but give the worker a fast index and search. And let the worker decide what to write.

The engineering post defines memory narrowly: knowledge kept between sessions. It leaves out changes to the model itself, learning inside one conversation, and compaction, which summarizes a long conversation to save space.1 It adds one more piece of advice: give each worker its own page, instead of one shared file.

Why plain Markdown files?

Because people and workers can both read them. Anthropic's memory work settled on a folder of Markdown files. The worker searches it with ordinary file tools, the way a coding agent searches a repository.2 An index at the top points down to pages, the way a skill's short description points to its body (Chapter 16). The worker reads the index every run, and opens a page only when its work needs it. Claude Managed Agents mounts a memory store as a directory inside the session's sandbox, for the same reason.3

What should a worker remember?

Only what it cannot look up again. A note is a prediction that a fact will matter later.1 An invoice's amount can be read from the connector every time, so a note about it is waste, and goes stale. It also fails Chapter 4's wipe test: if memory were wiped tonight, tomorrow's work must still be correct (4.3). The fact that Northfield's NA- documents are credits, with the invoice in the line text, is worth a note, because nothing in a single document says so. Anthropic's post reports a Claude model that played a video game. It wrote hundreds of memory files about things it could read off the screen, and spent its time searching them instead of playing. A later model kept a small folder of tested rules, and got much further.1

Tell the worker what memory is for, not how to use it. In the same post, telling strong models to "record only failures" took away much of what memory gained them.1 Brightline's instructions say: "Memory is for what you will need again and cannot look up: how this company's documents and tools behave, and corrections people gave you." They do not list what to write.

Why must the top layer stay small?

Every line in it is read, and paid for, on every run, and long instruction files are followed less well.1 Brightline keeps instructions.md under 40 lines and index.md to one line per page. A lesson can be published to a notes/ page without being added to the top layer. Those are two decisions, and 31.6 keeps them apart.

Check yourself

Question 1 / 2

0 answered

Which memory layer is read, and paid for, on every run?

  1. The components of agent memory (Lance Martin, Anthropic Engineering, 6 November 2026).↑↑2↑3↑4↑5↑6
  2. Learning while you sleep: Beyond memory to dreaming (Lamis Mukta, Anthropic, AI Native DevCon London, June 2026).↑↑2
  3. Memory stores (Claude Managed Agents documentation).↑
Owner
Panaversity