Quick Start
1
Enable with three lines
Set
prefetch=True on MemoryConfig and the agent recalls relevant memories before its first model call.2
Tune the budget
Cap how many memories are injected and how large the block can grow.
3
Cross-agent recall
Store facts with one agent and recall them in another by sharing the same backend and
user_id.How It Works
Prefetch searches long-term memory with the user prompt, dedupes and budgets the matches, then appends them to the system prompt before the first LLM call.Prefetch is default-off. When
prefetch is False (or there is no memory instance), the backend is never queried and the prompt is unchanged. Backend errors are swallowed at debug level — the turn continues without recalled context.Configuration Options
Full list of options, types, and defaults —
MemoryConfig
Identity scoping (
user_id, session_id) is inherited from the same MemoryConfig.
Common Patterns
Pattern 1 — Personal assistant with recalled preferences
Pattern 2 — Tight budget for cost control
Best Practices
Default-off is intentional
Default-off is intentional
Enable prefetch per agent, not globally, so you pay the backend query only on the turns that benefit from recalled context.
Pair with user_id
Pair with user_id
Without
user_id, prefetch searches the per-instance store — a fresh agent-<uuid> on every process. Set user_id so recalled memories persist across runs.Keep the token budget small
Keep the token budget small
prefetch_token_budget=512 is the ceiling, not the target. Large recalled blocks push out user context — start small and raise only when needed.Async works out of the box
Async works out of the box
The async path awaits async backends; sync backends are offloaded off the event loop. No extra configuration required.
Backend failures never break the turn
Backend failures never break the turn
Any backend error is logged at debug level and the agent proceeds without recalled context — prefetch never fails a turn.
Related
Memory
Memory backends and the remember/recall API
Knowledge
Add documents and URLs as agent knowledge

