Memory in Agents

How Agents Retain Information

Memory is how agents retain and access information across steps and sessions. Different memory types serve different purposes — choosing the right combination is a key design decision for any production agent.

Types of Agent Memory

1

In-context (short-term) — Everything in the current context window: goals, actions, observations, retrieved info. Zero latency, no retrieval needed. Limited by window size and ephemeral — gone when the session ends. Sufficient for short, single-session tasks.

2

Key-value external memory — Store facts with explicit keys, retrieve by key. Fast and simple. Good for structured state (user preferences, task progress). Requires knowing what to look for in advance.

3

Vector (semantic) external memory — Store content as embeddings, retrieve by semantic similarity. "What do I know about this user's past issues?" Good for unstructured info where the relevant content is not known in advance. Persists across sessions.

4

Episodic memory — Records of past interactions: what tasks were attempted, what worked, what failed. Enables the agent to learn from experience and apply successful approaches to similar future tasks.

5

Working memory — A scratchpad for intermediate computations and in-progress plans too large to hold in the main context. Implemented as an external key-value store the agent reads and writes explicitly.

Memory Management Challenges

Production considerations

Wrong memories mislead. Stale memories are incorrect. Unlimited accumulation is expensive. Long-term memory stores user data across sessions and requires appropriate security, access control, and consent. Define explicit policies for what to store, for how long, and who can access it.

Need Help?

Ask the AI assistant about agent memory types, in-context vs external memory, or how to design memory for multi-session agents.