Start with the fundamental challenge.
The bind: AI agents must act forward in time, but useful memory requires understanding backward — you only know what mattered after the fact.
Human analogy to anchor your understanding:
| Human Brain | AI Agent |
|---|---|
| Hippocampus captures experiences live | Session logs/transcripts capture interactions |
| Sleep consolidates memories | "Dreaming" reorganizes memory offline |
| Neocortex stores long-term knowledge | Memory notes, wikis, injected context |
Key distinction: Agent memory specifically means knowledge gained from experience and retained between sessions. It does not include:
- Weight changes from training
- In-context learning within one conversation
- Compaction summaries
Think of memory as a pyramid with four levels, bottom to top:
┌─────────────────────────────┐
│ INJECTED CONTEXT │ ← Loaded automatically every session
├─────────────────────────────┤
│ MEMORY REPRESENTATIONS │ ← Wikis, structured knowledge maps
├─────────────────────────────┤
│ MEMORY NOTES │ ← Claude's written observations
├─────────────────────────────┤
│ TRANSCRIPTS │ ← Raw searchable event logs
└─────────────────────────────┘
Dreaming is the process that moves information upward through these layers during idle time between sessions.
The core insight: Writing a memory note is actually a prediction.
When Claude writes down a rule, it is predicting: "A future version of me will need this."
How this works in practice — the CL-Bench example:
A benchmark asked Claude to answer database questions across sessions. After each answer, Claude learned whether it was right or wrong. The learning loop looked like this:
Get question wrong
↓
Record the failure
↓
Generate theories about why
↓
Test those theories
↓
Write a validated rule to memory
↓
Apply rule to future questions
Model progression showed increasing sophistication:
| Model | Memory Behavior |
|---|---|
| Sonnet 4.6 | Generated theories but never tested them |
| Opus 4.7 | Consolidated notes, marked confirmed vs. unconfirmed facts |
| Sonnet 5 | Marked confirmed answers, wrote corrections |
| Opus 5+ | Closed the full loop — rules, evidence, and trap warnings |
Takeaway: The ability to close a learning loop is a capability that improves with model sophistication.
This is where memory quality diverges dramatically between approaches.
The Pokémon experiment revealed two opposing strategies:
Sonnet 3.7 — Record Everything
Fable 5 — Record What Only Claude Can Know
global.mdThe key principle Fable 5 applied:
Don't store what you can read off the screen. Store what disappears unless you write it down.
| Not worth storing | Worth storing |
|---|---|
| Current money amount | Strategy rules Claude discovered |
| Player's map position | Plans for upcoming challenges |
| Items currently held | Tested tricks (e.g., timing Poké Ball throws) |
Fable 5's global.md acted as a dashboard — current goal, gym plan, and Claude's own rules for using memory.
Finding: Tell Claude what memory is for, not how to use it.
Evidence from CL-Bench:
When researchers gave Opus 5 and Opus 4.7 a specific rule — "record only failures" — performance actually dropped:
Stronger models perform better with freedom to judge salience themselves.
However, weaker models benefit from explicit guidance:
Practical rule:
Frontier models → Simple guidance, trust their judgment
Older/weaker models → Explicit step-by-step instructions help significantly
Dreaming is offline processing that improves memory between sessions. It has four distinct jobs:
The Mt. Moon example:
Claude incorrectly recorded that the PokéCenter was on the east side of the mountain. This caused it to:
With dreaming: Claude checked the note against the original transcript (ground truth), caught the error, rewrote it, and successfully navigated through.
Key mechanism: Transcripts serve as ground truth. Dreaming validates notes against transcripts.
For large knowledge bases, flat notes aren't enough. Dreaming can build wikis — linked pages that map what Claude knows.
Experiment with 350,000 files (~420M tokens):
| Sessions of Dreaming | Performance on 25 Questions |
|---|---|
| 2 sessions | 13% |
| 128 sessions | 48% |
Wiki + Search tool combined reached 61%, versus 53% for search alone.
Why wikis help:
When wikis don't help:
The top layer — injected context — loads automatically into every session without Claude needing to search.
Critical constraints:
How Claude Code handles this:
MEMORY.md fileDesign principle: The top layer is an index, not an archive.
Single sessions have limited context. Dreaming can search across many sessions to find patterns.
Example: After building a wiki, Claude had nine links pointing to a page that didn't exist. A second dreaming pass:
Also: Dreaming can optimize the instructions for building memory itself. When a wiki was missing contract terms because agents overwrote each other's work, a dreaming loop:
Result: Performance jumped from 72% → 100% of graded criteria.
The article closes with unresolved tensions. Understanding these shows mature comprehension:
| In-Session Writing | Dreaming |
|---|---|
| Immediately available | Available only after offline processing |
| Draws attention from main task | Runs in background |
| Captures salience at the source | Can review with fuller context |
SESSION HAPPENS
↓
Claude writes memory notes (predicting future relevance)
↓
Session ends → transcripts saved
↓
DREAMING (offline)
├── Validates notes against transcripts (corrects errors)
├── Builds/updates wikis (creates navigable knowledge maps)
├── Promotes key notes to injected context (always-available layer)
└── Fills cross-session gaps (finds patterns across many sessions)
↓
NEXT SESSION BEGINS
├── Injected context loaded automatically
├── Wiki available for navigation
├── Search available for transcripts
└── Claude acts with richer, more accurate memory
The central insight: Memory is not just storage — it is an active, maintained system that requires judgment about salience, validation against ground truth, and intelligent organization to be useful across time.