What Is Memory
Memory is the mechanism by which an AI agent retains information across conversation turns and sessions, and recalls it when needed. Where context engineering handles “what to show the model right now,” memory handles “what to keep around for later.”
Context vs. Memory
| Aspect | Context | Memory |
|---|---|---|
| Timeframe | What’s visible right now | What persists across turns and sessions |
| Role | Supplies the immediate judgment material | Storage that can be recalled later |
| Example | Current instructions, the last tool result | User preferences, past task history |
Information stored in memory is still passed to the model as context whenever it’s actually used. Memory is simply a storage layer that gets loaded into context later.
Short-Term vs. Long-Term Memory
| Type | Description | Implementation examples |
|---|---|---|
| Short-term memory | Working state valid only for the current session | Conversation history, the most recent tool result |
| Long-term memory | Information retained across sessions | User preferences, past task results, documents |
Patterns for Implementing Long-Term Memory
1. Compression via Summarization
Instead of keeping an entire conversation or log, summarize and store the important decisions, open issues, and constraints. Passing an entire long history every time crowds the context window and buries important information.
2. Recall via Vector Search
Store past information as vectors and use similarity search to recall only what’s relevant to the current task. This approach shares its underlying idea with RAG.
3. Structured Storage
User settings, profiles, and project constraints are easier to reference accurately later if stored as structured files or records rather than free-form text.
# Example user profile
Preferred answer style: Concise, bullet-point focused
Language: English
Project constraint: Never deploy to production without approvalThings to Watch Out For
- Don’t mix in stale information: Resolved issues or outdated hypotheses left in memory can lead the AI to reason from wrong assumptions
- Don’t store everything: Storing indiscriminately adds noise and buries what matters
- Keep provenance: Recording when and from which task a piece of information came makes it easier to spot when it’s gone stale
Pages in This Section
| Page | Content |
|---|---|
| Short-Term and Long-Term Memory | Lifespan and write criteria for each type |
| Memory Versus RAG | How to choose between two similar mechanisms |
| Long-Term Memory Storage Patterns | Comparing files, structured records, vector search, and summaries |
Summary
- Memory retains and recalls information across conversation turns and sessions
- If context is “what to show now,” memory is “what to keep for later”
- Short-term memory is conversation history; long-term memory is implemented via summarization, vector search, or structured storage
- Storing everything indiscriminately hurts quality — organizing stale information and tracking provenance matters more