An agent without memory is like an employee who forgets everything every morning. Memory systems give agents the ability to learn from past interactions, maintain context across sessions, and improve over time.
The current conversation — messages from the running session. Limited by the LLM's context window.
Implementation:
Information stored across sessions: user preferences, learned facts, project status.
Implementation:
Memories of past situations and their outcomes. "Last time, strategy X worked."
Implementation:
Similar to RAG — the agent has access to a knowledge base searched via embeddings.
Implementation:
interface AgentState {
messages: Message[] // Chat history
currentGoal: string // Active goal
plan: Step[] // Planned steps
completedSteps: Step[] // Completed steps
context: Record<string, unknown> // Collected context
}
Save agent state after every step. On errors, you can roll back to the last valid state — instead of starting from scratch.
For structured workflows (e.g., onboarding agent): Defined states with allowed transitions.
| Use Case | Recommended Memory | Example |
|---|---|---|
| Simple Chatbot | Short-term only | FAQ bot |
| Personal Assistant | Short + long-term | Calendar agent |
| Research Agent | Short + vector + episodic | Market analysis agent |
| Workflow Agent | Short + state machine | Onboarding agent |
Practical tip: Start with short-term memory. Add long-term memory when users interact across multiple sessions. Episodic memory is only worthwhile when the agent solves complex, recurring tasks.