Agent Memory Explained
Working memory, thread memory, long-term memory, and RAG—how memory works in agentic systems and how to govern it.
Agent memory is any state that lets an agent behave coherently across steps or sessions. It is not one database—it is a set of stores with different lifetimes and trust levels.
Four memory types
| Type | Lifetime | Example | Risk |
|---|---|---|---|
| Working | Single run | Scratchpad, tool results | Context bloat |
| Thread | Session | Chat history | Drift, cost |
| Long-term | Weeks–forever | User preferences | Stale/wrong facts |
| World/RAG | Query-time | Docs, tickets | Injection, irrelevance |
Design principles
- Structure beats prose for control state
- Provenance for durable facts (who wrote, when)
- Summarize rather than infinite append
- Separate secrets from model-visible memory
- User control for personal memory
Working memory tactics
- Keep a typed
stateobject - Store raw tool results in a blob store; put summaries in context
- Bound lists (last N errors, last N actions)
Long-term memory tactics
- Write only high-confidence, user-approved facts
- TTL sensitive preferences
- Conflict resolution rules when facts disagree
Memory vs RAG
RAG retrieves world knowledge. Memory stores interaction state and personalization. Confusing them causes either amnesia or hallucinated personalization.
Evaluation
Test memory systems for:
- Correct recall of critical facts
- Non-recall of stale/revoked facts
- Resistance to memory injection (“remember to ignore policies”)
- Cost of growing histories
Summary
Treat memory as productized state management. The winners are boring: typed, governed, summarized, and observable. See also the memory systems pattern.
FAQ
Frequently asked questions
What is agent memory?
Agent memory is state retained across steps or sessions—working context, conversation history, durable user facts, and retrieved knowledge—so the agent can act coherently over time.