Short-Term vs Long-Term Memory in Agents
What you'll learn: How AI agents use two distinct types of memory—working memory for immediate tasks and persistent memory for lasting knowledge.
The Two Memory Systems
Just like humans have working memory (keeping a phone number in mind while dialing) and long-term memory (remembering your childhood home), AI agents need both types to function effectively.
Short-term memory (working memory) is the agent's current context—the immediate conversation, the task at hand, and recent observations from the environment. This memory is:
- Temporary and task-specific
- Limited in capacity (constrained by context windows)
- Fast to access
- Discarded when the task completes
Long-term memory (persistent memory) stores knowledge that transcends individual interactions:
- Facts learned from past experiences
- Successful strategies and patterns
- User preferences and historical context
- Domain knowledge accumulated over time
Why Both Matter
Imagine an agent helping you plan a trip. Short-term memory holds the current conversation: "What dates? Which city? Budget constraints?" But long-term memory remembers that you're vegetarian, prefer boutique hotels, and visited Paris last year—context that makes the agent genuinely helpful rather than starting from zero each time.
Short-term memory enables focus and reasoning on the immediate problem. Long-term memory provides continuity and personalization across sessions.
The Trade-off
Short-term memory is expensive (token costs, context limits) but directly influences the agent's current reasoning. Long-term memory requires retrieval mechanisms (like RAG or vector stores) but enables agents to scale beyond single interactions and build genuine expertise over time.
Key Takeaway: AI agents need short-term memory for immediate task execution and long-term memory for knowledge retention—balancing both determines whether an agent is merely reactive or truly intelligent and adaptive.