Overview
Memory gives agents the ability to remember. Without it, everyagent.run() is a blank slate. With it, agents maintain conversation history, learn user preferences, track entities, remember decisions, and build knowledge graphs.
All memory features share a single storage backend and are configured through the memory field on AgentConfig.
Quick Start
UnifiedMemoryConfig
The complete memory configuration. Onlystorage is required — everything else is opt-in.
| Property | Type | Default | Description |
|---|---|---|---|
storage | StorageDriver | Required | Storage backend shared by all memory subsystems. See Storage |
maxMessages | number | 50 | Maximum messages kept in session history. Oldest are trimmed first when exceeded |
maxTokens | number | undefined | Token-based history trimming. When set, history is trimmed to fit within this token count (instead of message count) |
summaries | boolean | SummaryConfig | true (ON) | Long-term conversation summaries. Auto-summarizes overflow messages. Pass false to disable |
userFacts | boolean | UserFactsConfig | false (OFF) | Extract and store facts about the user (preferences, location, interests). Pass true for defaults |
userProfile | boolean | UserProfileConfig | false (OFF) | Structured user profile (name, role, timezone, language). Pass true for defaults |
entities | boolean | EntityConfig | false (OFF) | Entity memory — companies, people, projects extracted from conversations |
decisions | boolean | DecisionConfig | false (OFF) | Decision audit trail — what the agent decided and why |
learnings | LearningsConfig | undefined (OFF) | Vector-backed learned insights from interactions. Requires a vectorStore |
graph | GraphMemoryConfig | undefined (OFF) | Knowledge graph — entity-relationship graph with temporal awareness. Requires a GraphStore |
procedures | boolean | ProceduresConfig | false (OFF) | Procedural memory — records successful tool-call workflows for reuse |
contextBudget | ContextBudgetConfig | undefined | Token budget allocation for how memory context is distributed |
model | ModelProvider | Agent’s primary model | Separate (cheaper) model used for background extraction (summaries, facts, entities, etc.) |
Sessions and History
Sessions are the foundation. Everyagent.run() with a sessionId appends messages to a persistent history.
maxMessages is exceeded: The oldest messages are removed from the session. If summaries is enabled (the default), those removed messages are first summarized so the context isn’t lost entirely.
Token-based trimming: Instead of counting messages, you can limit by tokens:
Summaries
Default: ON. When session history overflowsmaxMessages, the overflow messages are summarized by the LLM and stored. These summaries are injected into the system prompt on future runs so the agent remembers older context.
SummaryConfig
| Property | Type | Default | Description |
|---|---|---|---|
maxCount | number | 10 | Maximum summaries stored per session. Oldest pruned first |
maxTokens | number | 2000 | Token budget for summary text injected into system prompt |
User Facts
Default: OFF. Automatically extracts persistent facts about the user from conversations: preferences, location, profession, interests, communication style. Facts are stored peruserId and injected into the system prompt on every run for that user, across all sessions.
UserFactsConfig
| Property | Type | Default | Description |
|---|---|---|---|
maxFacts | number | 100 | Maximum facts stored per user. Oldest pruned when exceeded |
- “User prefers dark mode”
- “User is a software engineer in Mumbai”
- “User’s favorite language is TypeScript”
invalidatedAt and the new one takes over.
User Profile
Default: OFF. A structured profile object with built-in fields (name, role, timezone, language) plus custom fields. More structured than user facts.UserProfileConfig
| Property | Type | Default | Description |
|---|---|---|---|
customFields | string[] | [] | Additional fields to track beyond the built-ins |
Entity Memory
Default: OFF. Extracts companies, people, projects, and products mentioned in conversations. Each entity has facts, events, and relationships.EntityConfig
| Property | Type | Default | Description |
|---|---|---|---|
namespace | string | "global" | Namespace for scoping entities. Supports hierarchical paths like "org/team/project" |
- Entity: “Stripe” (type: company) — facts: [“Payment processor”, “Used for billing”]
- Entity: “Raj” (type: person) — facts: [“Frontend engineer”, “Works on checkout”]
Decision Log
Default: OFF. Records what the agent decided and why. Useful for auditing and learning from past decisions.DecisionConfig
| Property | Type | Default | Description |
|---|---|---|---|
maxContextDecisions | number | 5 | How many recent decisions are injected into the system prompt |
log_decision, record_outcome, and search_decisions tools automatically.
Learned Knowledge
Default: OFF. Vector-backed insights that the agent learns over time. Requires a vector store for semantic search.LearningsConfig
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
vectorStore | VectorStore | Yes | — | Vector store for semantic search over learnings |
collection | string | No | "radaros_learnings" | Collection name in the vector store |
topK | number | No | 3 | Number of relevant learnings injected into context |
Graph Memory
Default: OFF. A knowledge graph where entities are connected by typed, directed relationships. Enables the agent to answer questions that require traversing relationships (e.g., “Who works with Raj?”).GraphMemoryConfig
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
store | GraphStore | Yes | — | Graph store backend (InMemoryGraphStore or Neo4jGraphStore) |
autoExtract | boolean | No | true | Automatically extract entities and relationships from conversations |
maxContextNodes | number | No | 10 | Maximum graph nodes injected into context |
Procedural Memory
Default: OFF. Records successful multi-step tool workflows and suggests them when similar tasks arise.ProceduresConfig
| Property | Type | Default | Description |
|---|---|---|---|
maxProcedures | number | 50 | Maximum stored procedures |
Context Budget
Controls how the memory context string is distributed across sections when injected into the system prompt.ContextBudgetConfig
| Property | Type | Default | Description |
|---|---|---|---|
maxTokens | number | undefined | Maximum total tokens for the entire memory context |
priorities | Record<string, number> | undefined | Weight for each section (higher = more budget). Keys: "summaries", "userFacts", "userProfile", "entities", "decisions", "graph", "procedures" |
Using a Cheaper Model for Extraction
All background extraction (summaries, facts, entities, profiles) uses the agent’s primary model by default. This can be expensive. Setmodel to use a cheaper model:
Full-Featured Example
Every option enabled:When to Enable What
| Feature | Enable When | Cost Impact |
|---|---|---|
| Sessions + Summaries | Always (default) | Low — 1 LLM call per overflow |
| User Facts | You need cross-session personalization | Low — 1 LLM call per run for extraction |
| User Profile | You need structured user data (name, role, timezone) | Low |
| Entities | Your conversations reference companies, people, projects | Medium — extraction call per run |
| Decisions | You need audit trails or want the agent to learn from past choices | Negligible — no LLM calls, just storage |
| Learnings | You want vector-search over accumulated knowledge | Medium — requires a vector store |
| Graph | You need relationship traversal (“who works with whom”) | Higher — extraction + graph storage |
| Procedures | Your agent repeats similar multi-tool workflows | Low |
Storage Options
Thestorage field accepts any StorageDriver. Choose based on your needs:
| Driver | Persistence | Best For |
|---|---|---|
InMemoryStorage | None (lost on restart) | Development, testing |
SqliteStorage | File-based | Prototypes, single-server apps |
PostgresStorage | Durable | Production |
MongoDBStorage | Durable | Production |
MySQLStorage | Durable | Production |
RedisStorage | In-memory with persistence | High-throughput, caching |
DynamoDBStorage | Durable | AWS-native, serverless |