Introducing Memory v2: Scoped Persistent Context
Agents are stateless by default. Every run starts from zero. Your agent greets the same user like a stranger every time.
Memory v2 changes this. Agents now remember per-user context, per-session state, and long-term knowledge — out of the box, with no external database required.
The problem with memory v1
Our first memory implementation was a single flat key-value store per agent. It worked for simple cases but fell apart at scale. Every user's context was mixed together. Session boundaries were unclear. There was no way to scope memory to a specific conversation without manual key management.
Teams ended up building their own memory layer on top of ours, which defeated the purpose.
How v2 works
Memory v2 introduces three scopes:
User memory. Persists across all sessions for a specific user. Stores preferences, history, and accumulated knowledge. When your agent remembers that a user prefers concise responses or that their company uses PostgreSQL — that is user memory.
Session memory. Persists within a single conversation. Stores the running context, previous tool results, and decisions made so far. When a user says refer to the invoice from earlier in this conversation — that is session memory.
Agent memory. Shared across all users and sessions. Stores learned patterns, frequently-used data, and cached tool results. When your agent knows that the Stripe API returns paginated results and pre-fetches accordingly — that is agent memory.
Automatic context management
Memory v2 handles context window management automatically. As conversations grow, older messages are compressed into running summaries. The agent always has the most relevant context within its token budget.
Vector search runs across all three scopes. When the agent needs to recall something, it queries user memory, session memory, and agent memory simultaneously and merges the results by relevance.
Configuration
Memory v2 works with zero configuration. Enable it with one line:
For fine-grained control, you can configure TTL, encryption, storage backends, and scope priorities:
Migration
If you are on Memory v1, the migration is automatic. Your existing key-value pairs are moved into the agent memory scope. No data is lost. No code changes required.
