Zenaique

What does Mem0 do between two turns of the same user's session?

Short answer·Medium·4.0 · 0·~3 min·Asked atServicenowSnorkel AiWriter
Attempt it

A user finishes turn 1 and is about to send turn 2. Describe the steps Mem0 takes between those turns and what it injects into turn 2's context.

Free · 2 AI evals / day
TL;DR

Between turns Mem0 extracts facts from the latest exchange, then adds, updates or deletes memories against similar stored ones (the paper's flow). Turn 2 gets only the top-k salient facts.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a friend who keeps a small notebook about you. After every chat, they spend a moment writing down anything new they learned in short sentences: 'Likes hiking.' 'Allergic to peanuts.' 'Moved to Berlin in July.' They cross-check the new notes against the old ones and merge any duplicates. They update an entry if something contradicts it (you used to live in NYC and now live in Berlin, so the entry gets updated). When you start talking again, they glance at the notebook. They pull out the few entries that seem relevant to what you are about to say and keep those in mind. They never re-read the whole notebook every time, only the relevant slice.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Mem0's design centers on two cognitive operations: extracting facts when memories are written, and retrieving the salient slice when memories are read. The work happens between turns and is invisible to the agent. The agent sees only a small injected memory block on each turn. The full archive, the extraction logic, the dedup and contradiction handling all live inside Mem0. The four-operation update step comes from the Mem0 paper.

The write path: extraction over the turn pair

After turn 1 completes (user message plus assistant reply), Mem0 runs an extraction LLM pass over the pair. In the paper, the extractor also sees a rolling conversation summary and the most recent messages for context. The extraction prompt is written to produce declarative facts in canonical form suitable for later vector retrieval.

The prompt instructs the model to identify durable, stable facts: user preferences, demographics, ongoing situations, key relationships, project context. It tells the model to skip content with no lasting value: greetings, filler, generic acknowledgments, and assistant replies that only restate what the user said.

The output is a list of candidate memories, each one sentence:

  • 'user is a vegetarian'
  • 'user is moving to Berlin in July'
  • 'user prefers Python over JavaScript for new projects'
  • 'user works at Anthropic as a research engineer'

This canonical-fact form is important. It makes embeddings more meaningful (similar facts cluster), it makes the store readable to humans (debug-friendly), and it makes retrieval more reliable (top-k returns coherent results).

Mem0 ships with a default extraction prompt that works for general conversational assistants. Teams often customize it for their domain; add() accepts a prompt argument for this. A medical assistant focuses on medications and conditions. A coding assistant focuses on language and framework preferences. An enterprise assistant focuses on project context and team relationships.

Dedup and contradiction resolution
The read path: salient-slice retrieval
What the agent does not see
Failure modes and operational discipline
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Mem0's hosted service is used in consumer chat products that need persistent user facts across sessions
  • The Mem0 paper (arXiv 2504.19413) evaluates the extract and update pipeline on the LOCOMO long-conversation benchmark
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you customize Mem0's extraction prompt for a domain-specific assistant?
A

Mem0's add() accepts a prompt argument for a custom extraction prompt. For a medical assistant, you would prompt the extractor to focus on medications, conditions, and allergies and to ignore conversational pleasantries. For a coding assistant, you would focus on language preferences, framework choices, and project conventions. Evaluate the extraction output on a sample of real dialogue before shipping the new prompt.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Imagining Mem0 stores raw conversation history and rebuilds it each turn. The unit of storage is a discrete extracted fact, and contradiction handling is part of the write path.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Name the extraction step and what it operates on (user message plus assistant reply)

  • Describe the update step: similar memories found by embedding similarity, then ADD, UPDATE, DELETE or NOOP

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
List the trace spans a context engineering pipeline should emit per call
Flashcard·Medium