Skip to main content
Memory enables agents to maintain coherance over multiple-turns. Agents store a history of messages that include:
  • System messages.
  • User messages.
  • Model responses.
  • Tool calls and their results.
Memory works automatically. Behind the scenes, it uses a two-tier architecture with recent messages in fast in-memory storage and optional database persistence for durability.
The agent automatically:
  1. Stores each user message in memory.
  2. Stores its own responses in memory.
  3. Stores tool calls and results in memory.
  4. Retrieves relevant history when building context.

Isolation

Isolated Conversations

Each conversation has its own isolated memory. Use different conversation identifiers to maintain separate conversation histories:

Isolated Users (Scope)

For multi-tenant applications, add a scope parameter to isolate memory across users:

Isolated Agents

Different agents have separate memory, even when serving the same user:

Memory Limits

By default, agents keep the last 100 messages or ~8,000 tokens in active memory (whichever limit is reached first). Older messages are automatically removed to stay within these limits. Messages are removed using FIFO (first in, first out) order - the oldest messages are removed first.

Memory and Context

Memory stores all conversation messages, but agents don’t always send all messages to the model. The Context template determines which messages to included in calls to the model.