Instantiate memory: from mem0 import Memory; m = Memory()
After each agent turn, store new facts: m.add(messages, user_id='user-123') — Mem0 extracts and deduplicates facts automatically
Before each LLM call, retrieve relevant memories: memories = m.search(query=user_message, user_id='user-123') and inject them into the system prompt
Use user_id for user-scoped memory, session_id for session-scoped memory, and agent_id for agent-scoped memory — scopes do not bleed into each other
For production, configure Mem0 with an external vector store backend (Qdrant, Pinecone, etc.) rather than the default in-memory store
Known gotchas
Mem0 performs automatic fact extraction on add() using an LLM call — this adds latency and cost per turn; batch or debounce adds for high-throughput agents
Memory search returns results ranked by similarity, not recency — if temporal ordering matters use Zep, which tracks when facts became true and when they were superseded
The default in-memory backend resets on process restart — always configure a persistent vector store for production deployments
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp