In plain terms
A session is the running transcript of one conversation. It’s how the agent remembers what was said two messages ago — and two days ago, if it’s the same session. History survives a process restart only when the configured storage persists it. A fallback or explicit in-memory store loses it when the process ends. Agents keep fallback session history without explicit memory configuration. Addingmemory.storage selects its storage backend and enables the configured unified-memory features.
When to use it
Use sessions for a continuing conversation; use a fresh owned session for independent work. Choose a storage driver explicitly when its lifetime matters. This host function receives a configured model and host-owned storage:When you don’t need it
- One-shot, stateless calls (a classify-this-text endpoint that never has a follow-up). You can still pass
storage; it just won’t matter. - For cross-session memory (“remember me next week, in a new conversation”), sessions alone aren’t enough — turn on User Facts, which persist across all of a user’s sessions.
Configuration
maxMessages vs maxTokens: use maxMessages for simplicity (predictable, easy to reason about). Use maxTokens when message lengths vary wildly and you want to budget history when message lengths vary. Account separately for instructions, tools, memory context, and output.
Sessions vs other stores
Cross-references
- Memory Overview — how all the stores fit together
- Summaries — what happens to overflow messages
- Incremental Sessions — append-only session storage for high write throughput
- Storage Backends — where sessions are persisted