3 Layers of AI Agent Memory (And How Claude Dreaming Changes the One That Matters Most)
Most AI agents forget everything the moment a session ends. Here is how the memory stack actually works, layer by layer, and what Claude…

3 Layers of AI Agent Memory (And How Claude Dreaming Changes the One That Matters Most)
Most AI agents forget everything the moment a session ends. Here is how the memory stack actually works, layer by layer, and what Claude Dreaming does differently at the top.
Harvey, the legal AI company, switched on a new Anthropic feature for their document drafting agents in early May 2026.
The agents were handling legal workflows: reviewing file docs, drafting contracts, managing filetypes and tool-specific quirks across sessions.
Before the feature: those same jobs failed repeatedly. The agent kept forgetting things it had already figured out. Filetype quirks. Tool workarounds. Patterns it had encountered dozens of times. Each new session, the same mistakes.
After enabling it:
Task completion rates jumped roughly 6x.
The feature was called Dreaming.
Anthropic launched it on May 6, 2026, at their Code with Claude conference, currently in research preview for developers.
This article explains why AI memory is hard from first principles, how the three-layer memory stack works, and exactly what Dreaming does that standard memory systems do not.
If you want more such information about AI, consider subscribing to my newsletter, where you will get noise-free information every week
Link for the newsletter: Newsletter
Why do LLMs have a memory problem at all

Most people assume AI models are like software programs. Run the code, and it remembers what it did and picks up where it left off.
That is not how LLMs work.
An LLM takes input, predicts the next token, and produces output. That is the full cycle.
No persistent state. No internal storage. No memory of what came before, unless you explicitly give it that context in the input.
LLMs are stateless by default. Every conversation starts from zero, unless you engineer around it.
Tell Claude your name in one session. Open a new session the next day. It has no idea who you are. Not a bug. The new session is a fresh input with no link to anything before it.
Every AI memory system is trying to work around this. Doing it properly takes at least three layers.

Layer 1: Short-term memory (the context window)
The first and simplest fix is to give the model its own conversation history.
When you send a new message in an active chat, the system does not just send your message to the model. It sends your entire conversation history plus your new message as one big combined input. The model reads all of it and responds accordingly.
That is short-term memory. The model appears to “remember” what you said five minutes ago because it is reading that message again as part of the current input.
What actually gets sent to the LLM each turn:
[Turn 1: User said X]
[Turn 1: AI replied Y]
[Turn 2: User said A]
[Turn 2: AI replied B]
[Turn 3: User said ← your actual new message]
It works. Within a session, the agent tracks context, builds on earlier points, and feels coherent.
Two problems kill it on long tasks:
- Session end: Close the chat and the history is gone. Next session starts completely empty.
- Context window limit: The model can only ingest so many tokens at once. Long enough conversations push older messages out. The model forgets the beginning of its own session.
Short-term memory solves the within-session problem. It does nothing for the across-session problem.
Layer 2: Long-term memory (external stores)
To survive across sessions, agents need to write information somewhere and retrieve it later.
The standard approach: after each session, a background process reads the conversation, extracts key facts, and saves them as structured entries in a database.
Session ends → background process runs → extracts facts → writes to store
"Name: Divy"
"Prefers: no em dashes in writing"
"Stack: Python, LangGraph, Postgres"
"Current project: personal portfolio site"
When the user starts a new session, the relevant facts get retrieved and injected into the new context. The agent reads those facts and behaves as if it remembers.
This works well enough for simple factual recall. The problem shows up when conversations carry something more subtle than facts.
Say you complained three sessions ago that the AI was giving you bullet-point-heavy answers when you wanted flowing prose. That feedback is not a simple fact. It is behavioral. It requires the system to read the conversation holistically, notice your dissatisfaction, figure out what you wanted instead, and save that as an instruction.
Traditional long-term memory, which works sentence by sentence, misses this. It might save “User asked for prose” if you said it explicitly. But it will not catch the frustration embedded in the conversation pattern itself.
Saving facts is not the same as learning from experience. That distinction is what Claude Dreaming is built around.
Layer 3: Claude Dreaming (memory consolidation)
Dreaming was announced on May 6, 2026, at Anthropic’s Code with Claude conference. It is currently in research preview, available on Claude Opus 4.7 and Claude Sonnet 4.6, gated behind a developer request form.
It is not a new model. It does not change Claude’s underlying weights. Think of it as a maintenance process that runs on top of the external memory store.
Here is what makes it different from standard long-term memory.
What Dreaming actually does

Standard long-term memory reads one session and extracts facts.
Dreaming reads up to 100 past sessions alongside the entire existing memory store, and then produces a completely reorganized, cleaned memory store.
The process runs four phases, documented in Anthropic’s Claude Code implementation:
Phase 1: Orient. The dream process reads the current MEMORY.md index and recent session transcripts. It maps what it already knows against what just happened. This is the “where am I starting from” phase.
Phase 2: Extract patterns across sessions. Instead of reading one conversation, it reads dozens simultaneously. It is looking for things that appear repeatedly. Recurring mistakes. Workflows that consistently produced better results. Preferences that came up in five different sessions. Things that no single session log could surface.
Alex Albert, Anthropic’s head of research product management, described this in an interview at the conference: “They’re learning to write better notes for their future self.”
Phase 3: Restructure the memory store
This is the cleanup. Dreaming does four specific things to the memory store:
- Merges duplicates. Three sessions noted the same build command quirk. Those consolidate into one clean entry.
- Removes stale entries. Debugging notes for a deleted file get pruned. “API uses Express” gets removed if you switched to Fastify three weeks ago.
- Deletes contradictions. The newer fact wins. Old conflicting entries are gone.
- Converts relative dates to absolute. “Yesterday we decided to use Redis” becomes “On 2026–05–01 we decided to use Redis.” This prevents temporal confusion as memories age.
Phase 4: Update the index
The MEMORY.md index file, kept under 200 lines to stay within startup load limits, gets rewritten to reflect the current state of all memory files accurately.
What this looks like across time
STANDARD LONG-TERM MEMORY:
Session 1 → write facts → store
Session 2 → write facts → store (growing, unmanaged)
Session 3 → write facts → store (duplicates accumulating)
Session 10 → retrieve from store → contradictory facts,
stale entries, noise
CLAUDE DREAMING:
Session 1-10 happen → store grows
DREAM RUNS (reviews all 10 sessions + store)
→ duplicates merged
→ stale entries removed
→ contradictions resolved
→ patterns extracted that no single session saw
Session 11 → retrieve from cleaned, organized store
→ agent behaves like it learned from 10 sessions, not just 1
That is why Harvey’s numbers moved so much. Legal agents kept hitting the same file type quirks across sessions.
Standard memory saved a note once. Dreaming read across dozens of sessions, spotted the repeating pattern, and gave the next session one clean, accurate instruction instead of scattered duplicates.
The four memory types in Anthropic’s architecture
Understanding where Dreaming fits requires knowing the full memory picture Anthropic describes for agentic systems. There are four distinct layers:

Most agent memory systems operate at layer two: external memory. They store and retrieve facts.
Dreaming adds a maintenance layer on top of that: a scheduled process that keeps the external memory store clean, current, and genuinely useful.
Dreaming is not replacing RAG (retrieval-augmented generation). RAG retrieves relevant documents to answer a question. Dreaming reorganizes what gets stored in the first place, so RAG retrieval returns better material. The two work together.
The real-time version: monitoring during a session
Dreaming runs between sessions. But there is a related idea worth knowing: real-time adjustment during a live conversation.
Some voice agent systems run a parallel monitoring process while the main agent talks. If the user sounds frustrated, the monitor sends a signal: “adjust your tone.” If an explanation is not landing, it flags: “try a different angle.” This runs in the background, invisibly, during the session itself.
Dreaming and this approach solve different parts of the same problem. Dreaming improves what the agent knows before a session starts. Live monitoring adjusts how the agent behaves while a session is running. A well-built agent system would eventually use both.
How to trigger a Dream and what it costs
Dreaming can run on a schedule (nightly is the common pattern) or be triggered manually with the /dream command.
The cost is standard API token rates. A single dream that processes 100 sessions involves reading a large number of tokens and writing a reorganized memory store. Anthropic has not published specific pricing for Dreaming beyond “standard token rates,” so the actual cost depends on session length and memory store size.
Access is currently behind a request form. Dreaming is not available in the Claude consumer app. It is an API and managed agent feature for developers building production systems.
Supported models: Claude Opus 4.7 and Claude Sonnet 4.6.
What Dreaming cannot do
Being precise about the limits matters.
Dreaming does not change Claude’s model weights.
An agent that dreams regularly does not become a different model. The base model’s capabilities stay fixed. What changes is the quality and organization of the external memory store that gets loaded into context each session.
If the sessions themselves contain bad information, Dreaming will consolidate bad information efficiently. Garbage in, organized garbage out.
Dreaming also does not solve context window limits within a session. Even with a well-organized memory store from Dreaming, very large stores need smart retrieval logic. Not every memory should load for every session. The indexing and retrieval layer still matters.
And privacy is a real architectural consideration. Session logs contain sensitive information. Any system using Dreaming needs data retention policies, access controls, and clear rules about what gets logged and for how long.
Dreaming is a memory maintenance system, not a learning system. It reorganizes what the agent already knows. It does not give the agent the ability to figure out things it could not figure out before.
Key Takeaways
- LLMs are stateless. Short-term memory (the context window) handles within-session recall. Long-term memory (external stores) handles across-session recall. Both have hard limits.
- Standard long-term memory saves facts. It cannot extract behavioral patterns or clean up its own contradictions over time.
- Claude Dreaming runs as a scheduled background process, reads up to 100 past sessions plus the existing memory store, and produces a reorganized, deduplicated, contradiction-free memory store.
- The four cleanup operations: merge duplicates, remove stale entries, delete contradictions, and convert relative dates to absolute.
- Harvey reported a 6x improvement in task completion for legal-drafting agents after enabling Dreaming.
- Current status: research preview on Claude Opus 4.7 and Claude Sonnet 4.6, developer request form required.
- Dreaming works on external memory. It does not update model weights, does not solve context limits within a session, and does not eliminate the need for good retrieval logic.
Conclusion
Most AI memory discussions focus on how much an agent can remember. The better question is whether what it remembers is still accurate.
A memory store with no maintenance gets noisier over time. Contradictions pile up. Stale facts stick around. The agent retrieves garbage alongside what is useful and its behavior gets unreliable.
Dreaming bets that memory quality matters more than memory size. Harvey’s 6x jump in task completion came from agents that stopped relearning the same lessons. The model did not change. The memory did.
That is the whole idea.
References
- Anthropic. New in Claude Managed Agents. 2026. https://claude.com/blog/new-in-claude-managed-agents
- Anthropic. Claude Code Documentation. https://code.claude.com/docs/en/overview
- Reuters. Anthropic unveils “Dreaming” feature to help AI agents self-improve. 2026. https://www.reuters.com/business/retail-consumer/anthropic-unveils-dreaming-feature-help-its-ai-agents-self-improve-2026-05-06/
- VentureBeat. Anthropic introduces Dreaming, a system that lets AI agents learn from their own mistakes. 2026. https://venturebeat.com/technology/anthropic-introduces-dreaming-a-system-that-lets-ai-agents-learn-from-their-own-mistakes/
- Ars Technica. Anthropic’s Claude can now “dream” — sort of. 2026. https://arstechnica.com/ai/2026/05/anthropics-claude-can-now-dream-sort-of/
- Forbes. Claude’s New Dreaming Feature Builds Self-Improving AI Agents. 2026. https://www.forbes.com/sites/jonmarkman/2026/05/11/claudes-new-dreaming-feature-builds-self-improving-ai-agents/
- Decode The Future. Claude Code Auto Dream Explained. https://decodethefuture.org/en/claude-code-auto-dream-explained/
- GitHub. dream-skill repository. https://github.com/grandamenium/dream-skill
메타데이터
- post_id
- d31d9a7dee61
- slug
- 3-layers-of-ai-agent-memory-and-how-claude-dreaming-changes-the-one-that-matters-most-d31d9a7dee61
- url
- https://medium.com/ai-engineering-simplified/3-layers-of-ai-agent-memory-and-how-claude-dreaming-changes-the-one-that-matters-most-d31d9a7dee61
- canonical_url
- https://medium.com/ai-engineering-simplified/3-layers-of-ai-agent-memory-and-how-claude-dreaming-changes-the-one-that-matters-most-d31d9a7dee61
- author_url
- https://medium.com/@yadavdivy296
- status
- ok
- fetched_at
- 2026-06-15 20:49:13