Quick Start
Level 1 — Bool (simplest)
Turn on memory with a single flag — the agent remembers across turns using the default file backend.
Level 3 — Config class (full control)
Use
MemoryConfig to scope memory per user and auto-extract facts.How It Works
| Phase | What happens |
|---|---|
| 1. Store | Each conversation turn is saved to the memory backend |
| 2. Retrieve | Relevant past context is recalled before responding |
| 3. Respond | Agent answers with full historical context available |
Which Backend to Choose?
Configuration Options
Full list of options, types, and defaults —
MemoryConfig| Option | Type | Default | Description |
|---|---|---|---|
backend | str | "file" | Storage backend: file, sqlite, redis, postgres, mem0, mongodb |
user_id | str | None | None | User identifier for scoped memory |
auto_memory | bool | False | Auto-extract and store key facts |
learn | bool | LearnConfig | None | None | Enable continuous learning |
history | bool | False | Auto-inject session history into context |
Common Patterns
Pattern 1 — User-scoped memory
Pattern 2 — History injection for conversation continuity
Best Practices
Always set user_id for multi-user apps
Always set user_id for multi-user apps
Without
user_id, all users share the same memory store. Set user_id to a unique identifier per user to keep memories properly scoped and private.Use auto_memory for fact extraction
Use auto_memory for fact extraction
Enable
auto_memory=True to have the agent automatically identify and store important facts from each conversation — names, preferences, decisions — without extra code.Combine memory with learning
Combine memory with learning
Set
learn=True inside MemoryConfig to enable continuous learning alongside session memory. This gives agents both short-term context (memory) and long-term pattern recognition (learn).Backend scaling path
Backend scaling path
Start with
file, move to sqlite when you need durability, then redis when you deploy multiple agent instances that share memory.Related
Learn
Learn — continuous learning from conversations
Knowledge
Knowledge — add documents and URLs as agent knowledge

