Skip to main content
The Memory system intelligently manages conversation history.

Memory vs KV Store

Memory is built for conversation context — message history, summaries, who spoke last, session status. Its content is managed: old turns are trimmed by maxTurns/maxTokens and compacted by summarization, so what you appended yesterday may only survive as part of a summary. That makes Memory the wrong place to park business data. If you need a value to come back exactly as you stored it — a cart, a feature flag, a counter, a customer preference — use the KV Store instead.
Appending fake messages to conversation history to persist arbitrary data is unreliable — summarization can compact it away and every message inflates the context sent to the LLM. Store data in the KV Store; keep Memory for the conversation. See Abandoned Cart Recovery for the two working together.

Memory Integrated in Agent

Standalone Memory Manager

Memory with User Identification

Custom Memory Key

Cross-Session Access

Listing Sessions

Memory.list() queries all sessions for the current agent with filtering. Each result includes the last message, so you can decide what to do without loading the full conversation.
Each session in the result includes:

Checking Who Spoke Last

Use lastMessage.role to know if the user or the agent was the last to speak — useful for deciding whether to follow up:
Don’t use identify() in a loop — it sets a global singleton that would get overwritten on each iteration. Pass entityType/entityValue directly in the agent.process() input instead.

Session Status

Mark sessions with a status to track their lifecycle. Status is stored in session metadata — no migration needed.
The best pattern is to let tools set the status — the LLM decides when to call them based on the conversation:
The developer never calls Memory.setStatus() directly — the tools do it. The agent’s instructions guide the LLM to use the right tool at the right time.

Status Lifecycle

See the SDR Agent with Follow-ups use case for a complete working example using Memory.list(), Memory.setStatus(), and scheduled callbacks.

Custom Summarization

Memory Configuration Options

Cross-agent memory administration

The Memory module operates on the caller’s own agent context — its key is prefixed with the caller’s agentId so each agent has its own namespace. To curate another agent’s memory (inject a system message, clear stale sessions, audit messages, summarize), use the MemoryAdmin module from the cross-agent SDK. Same six operations, but you pass the target agent explicitly and the backend prefixes the key with the target’s id instead of the caller’s.
Tenant-isolated: cross-tenant references return 404. See Cross-Agent SDK for the full reference and recipes (curator agent, follow-up agent).

Next Steps

Context Management

Learn about context management

Cross-Agent SDK

Operate on another agent’s memory and executions

Tools

Create custom tools

Abandoned Cart Recovery

Complete project: conversation in Memory, cart state in KV