Agent Memory Explained
Working memory, thread memory, long-term memory, and RAG—how memory works in agentic systems and how to govern it.
- memory
- architecture
- rag
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.
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.
Related reading
Memory Systems Pattern
Patterns for agent memory: working state, summaries, long-term stores, and retrieval with governance.
Memory
Agent memory is retained state across steps or sessions, including working context, thread history, durable facts, and retrieved knowledge.
Agentic Architecture: Core Components of Production Agents
A practical architecture model for agentic systems: goals, planners, tools, memory, orchestration, evals, and control planes.