Skip to main content
AI assistants plugged with memory systems face a problem - they often store everything. Not every conversation needs to be remembered, and not every detail should go to the memory store. Without proper controls, memory systems accumulate unreliable data. Mem0 lets you control your memory ingestion pipeline. In this cookbook, we’ll demonstrate these controls using a medical assistant example - showing how to filter unwanted data, enforce data formats, and implement confidence-based storage.

Overview

Without controls, everything gets stored - speculation, low-confidence data, and information that shouldn’t persist. This uncontrolled ingestion leads to cluttered memory and retrieval failures. Mem0 provides three tools to control what gets stored:
  1. Custom instructions define what to remember and what to ignore.
  2. Confidence thresholds ensure only verified facts persist.
  3. Memory updates let you change information without creating duplicates.
In this tutorial, we will:
  • Filter speculative statements with custom instructions
  • Configure confidence thresholds for fact verification
  • Update stored information without duplication
  • Build a complete ingestion pipeline

Setup

Replace your-api-key with your actual Mem0 API key from the dashboard. Without proper API authentication, memory operations will fail.

The Problem

Uncontrolled ingestion stores everything, including speculation:
Output:
Without custom instructions, AI assistants treat speculation as confirmed facts. “I think I might be allergic” becomes “Patient is allergic”: a dangerous transformation in sensitive domains like healthcare, legal, or financial services.
The speculation became a confirmed fact. Let’s add controls.

Custom Instructions

Custom instructions tell Mem0 what to store and what to ignore.
Output:
Expected output: Zero memories stored. The speculative statement “I think I might be allergic” was filtered out before reaching storage. Custom instructions are actively blocking unreliable data.
The speculation was filtered out.

Designing Custom Instructions

When designing instructions, consider the trade-off between precision and recall: Too restrictive: You’ll miss important information (false negatives)
Too permissive: You’ll store unreliable data (false positives)
Balanced approach:
Start with strict instructions (only store confirmed facts), then relax them based on your use case. It’s easier to allow more data than to clean up polluted memory. Test with sample conversations before deploying to production.
Start with clear categories and iterate based on retrieval quality.

Confidence Thresholds

Mem0 assigns confidence scores to extracted memories. Use these to filter low-quality data.

Setting Thresholds

Setting the right confidence threshold depends on your application:
  • High-stakes domains (medical, legal): Require 0.8+ confidence
  • General assistants: 0.6+ confidence is often sufficient
  • Exploratory systems: Lower thresholds (0.4+) capture more data
Test your pipeline with multiple input examples and threshold combinations to find what works for your use case.
Output:
Expected behavior: Low-confidence extractions are now filtered out automatically. Only verified facts with specific details (names, dates, dosages) persist in memory. The confidence threshold is working.
The vague statement was filtered for low confidence. The confirmed fact with specific details was stored.

Filtering Sensitive Information

Custom instructions can prevent storing personal identifiers:
Output:
The SSN was filtered out, but the allergy was stored.

Updating Memories

When information changes, update existing memories instead of creating duplicates.
Output:

Benefits of Updating

Preserves history:
  • created_at shows when the memory was first stored
  • updated_at shows when it was modified
  • Audit trail for compliance
Avoids conflicts:
  • No duplicate or contradicting memories
  • Single source of truth for each fact
That “no duplicates” promise comes from the inference pipeline. Keep infer=True when you rely on automatic updates. Raw imports (infer=False) skip conflict checks, so mixing the two modes for the same fact will create duplicates.

Pick the right inference mode

ModeWhat it doesBest forWatch out for
infer=True (default)Runs the LLM pipeline so Mem0 extracts structured facts and resolves conflicts automatically.Daily conversations, preference tracking, anything you want deduped.Slightly slower because inference runs on every write.
infer=FalseStores your payload exactly as-is: no inference, no dedupe.Bulk imports, compliance snapshots, curated facts you already trust.Later infer=True calls for the same fact will create duplicates you must clean manually.
Stay consistent per data source. If you need both behaviors, keep them in separate scopes (e.g., different app_id or run_id) so you always know which memories are inferred vs direct imports.

Update vs Delete

When should you update vs delete?

Update when:

  • Information changes but remains relevant
  • You need audit history
  • The memory has relationships to other data

Delete when:

  • Information was completely wrong
  • Memory is no longer relevant
  • Duplicate entry

Putting It Together

Here’s a complete ingestion pipeline with all controls:
Output:

Per-Call Instructions

You can override project-level instructions for specific conversations: First define custom instructions
This is useful for:
  • Different conversation types (emergency vs routine)
  • Channel-specific rules (phone vs in-person)
  • Temporary data collection that needs review

What You Built

You now have a medical assistant with production-grade memory controls:
  • Custom instructions - Filter speculation and enforce confirmed facts only
  • Confidence thresholds - Gate extractions below 0.7 confidence score
  • Memory updates - Modify stored information without creating duplicates
  • Per-call instructions - Apply temporary rules for specific conversations
  • PII filtering - Block sensitive data (SSNs, insurance numbers) automatically
These controls prevent retrieval failures and ensure your AI assistant works with reliable, verified information.

Summary

Start with conservative filters (only store confirmed facts) and iterate based on your application’s needs. Combine custom instructions with confidence thresholds for the most reliable memory ingestion pipeline.

Build a Mem0 Companion

Learn core memory patterns including temporary vs permanent data handling.
Using Mem0? Star us on GitHub to help more developers discover memory for AI apps.