add, then call search before the next model request to fetch relevant context. Your app decides which returned memories to include in the prompt.
Use Mem0 when you want agents to remember useful facts across turns, sessions, or users without replaying the full transcript every time.

The mental model
| Without a memory layer | With Mem0 |
|---|---|
| Keep appending chat history to the prompt | Store facts once, then retrieve them by query |
| Make the model re-read old turns | Give the model only the relevant memories |
| Lose context when a session ends | Scope memory by user_id, agent_id, run_id, and metadata |
Messages vs memories
You send Mem0 messages. By default, Mem0 stores extracted memories, not a verbatim transcript.| Input | Stored memory |
|---|---|
"I prefer aisle seats" | User prefers aisle seats |
"Let's use Postgres for this project" | Project decision: use Postgres |
| Message metadata | Filterable fields such as category, app, user, or run |
infer=False when you need to store raw content exactly as provided. Otherwise, keep inference enabled so retrieval works on clean, deduplicated facts.
Two phases: extraction and retrieval
Most applications use Mem0 in two places:- After a useful interaction, call
addto store what should be remembered. - Before a model call, call
searchand pass the best results into your prompt.
1. Extraction (writing memory)
When new messages arrive, Mem0 extracts durable facts and stores them with the identifiers and metadata you provide.- Context lookup. Mem0 checks related existing memories so it can avoid storing the same fact again.
- Fact extraction. An LLM extracts preferences, decisions, plans, and other details your agent can reuse.
- Deduplication and embedding. Redundant facts are removed, then each memory is embedded for semantic search.
- Entity linking. When configured, Mem0 links people, places, organizations, and concepts across memories.
update or delete operations when your application needs to correct or remove a memory.
2. Retrieval (reading memory)
When you callsearch, Mem0 ranks stored memories against your query and filters.
| Signal | What it does | Best for |
|---|---|---|
| Semantic | Vector similarity over embeddings | Conceptual questions |
| Keyword | Term matching for exact words and phrases | Names, IDs, and factual lookups |
| Entity | Boosts memories linked to entities in the query | Questions about a person, project, or account |
Always scope searches with filters such as
user_id, agent_id, or run_id. This keeps memories from different users, agents, or sessions from mixing.Where memories live
Mem0 stores different parts of a memory in stores built for different lookup patterns:| Store | Holds | Purpose |
|---|---|---|
| SQL database | Facts and metadata | The source of truth for each memory |
| Vector database | Embeddings | Semantic similarity search |
| Entity or graph store | Entities and relationships | Relationship-aware retrieval when graph memory is enabled |
Build against this flow
- Call
addonly for information worth reusing later: preferences, decisions, account facts, goals, and durable feedback. - Call
searchbefore the model response, then include only the returned memories that help answer the current request. - Use metadata for filters your product already cares about, such as workspace, feature area, tenant, or data source.
- Avoid storing secrets, raw credentials, or unredacted sensitive data. Mem0 is designed to retrieve stored context.
Next steps
Memory types
Choose the right scope for user, agent, run, and session memory.
Memory operations
Add, search, update, and delete memories from your app.
See the benchmarks
Review the evaluation setup and benchmark results.