User Memory
RadarOS agents can remember facts about users across sessions. TheUserMemory class automatically extracts personal details from conversations — like preferences, location, profession — and injects them into future interactions for personalized responses.
This is different from session memory, which stores conversation history within a single session. User memory persists per user, not per session.
Quick Start
Storage is automatically initialized by both
UserMemory and Agent — no need to call storage.initialize() manually.How It Works
Facts are auto-extracted
After each run, the agent fires a non-blocking LLM call to extract personal facts from the conversation (e.g., “Lives in Mumbai”, “Prefers concise answers”). This happens in the background and does not add latency to the response.
Facts are stored
Extracted facts are deduplicated and persisted in the storage driver under the
memory:user namespace, keyed by userId.Configuration
Storage driver for persisting user facts. Defaults to
InMemoryStorage. Use MongoDBStorage, PostgresStorage, or SqliteStorage for persistence.LLM used for automatic fact extraction. If not provided, the agent’s own model is used as a fallback.
Maximum number of facts stored per user. When exceeded, the oldest facts are dropped.
Enable or disable auto-extraction. When disabled,
getContextString() returns empty and extractAndStore() is a no-op.Methods
| Method | Returns | Description |
|---|---|---|
getFacts(userId) | Promise<UserFact[]> | Get all stored facts for a user |
addFacts(userId, facts, source?) | Promise<void> | Manually add facts (deduplicates automatically) |
removeFact(userId, factId) | Promise<void> | Remove a specific fact by ID |
clear(userId) | Promise<void> | Clear all facts for a user |
getContextString(userId) | Promise<string> | Formatted facts string for system prompt injection |
extractAndStore(userId, messages, model?) | Promise<void> | Extract facts from messages and store them |
asTool(config?) | ToolDef | Create a tool the agent can call to recall user facts |
UserFact Type
source: "auto". Manually added facts have source: "manual".
asTool() — Let the Agent Recall Facts On Demand
Instead of only injecting facts into the system prompt, you can give the agent a tool to actively look up user facts when asked. This is useful for queries like “What do you know about me?”.ctx.userId from the run context automatically — no manual wiring needed.
Smart deduplication: When
asTool() is registered in the agent’s tools, RadarOS automatically skips injecting user facts into the system prompt to avoid duplication. The agent retrieves facts on demand via the tool instead, saving tokens.Options
What Gets Extracted
The extraction LLM is prompted to identify:- Preferences (e.g., “Prefers concise answers”)
- Location (e.g., “Based in Mumbai”)
- Profession (e.g., “TypeScript developer”)
- Interests (e.g., “Loves building AI tools”)
- Goals and communication style
Manual Fact Management
You can also manage facts programmatically:Storage Options
Session Memory vs User Memory
Session Memory
Stores conversation history per session. Used for multi-turn context within a single conversation. Configured via
memory in AgentConfig.User Memory
Stores personal facts per user. Persists across sessions. Used for cross-session personalization. Configured via
userMemory in AgentConfig.User Memory in Voice Agents
UserMemory also works with Voice Agents. The VoiceAgent handles everything internally:
- On
connect({ userId }), stored facts are loaded and appended to the voice agent’s instructions - During the conversation, transcripts are collected
- On disconnect, transcripts are consolidated (fragmented speech deltas merged) and facts are auto-extracted
Voice agents use
UserMemory but not Memory (long-term summarization). The realtime API manages its own conversation context. Only UserMemory persists across voice sessions.