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:- Custom instructions define what to remember and what to ignore.
- Confidence thresholds ensure only verified facts persist.
- Memory updates let you change information without creating duplicates.
- 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:Custom Instructions
Custom instructions tell Mem0 what to store and what to ignore.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.
Designing Custom Instructions
When designing instructions, consider the trade-off between precision and recall: Too restrictive: You’ll miss important information (false negatives)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
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.
Filtering Sensitive Information
Custom instructions can prevent storing personal identifiers:Updating Memories
When information changes, update existing memories instead of creating duplicates.Benefits of Updating
Preserves history:created_atshows when the memory was first storedupdated_atshows when it was modified- Audit trail for compliance
- No duplicate or contradicting memories
- Single source of truth for each fact
Pick the right inference mode
| Mode | What it does | Best for | Watch 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=False | Stores 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. |
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:Per-Call Instructions
You can override project-level instructions for specific conversations: First define custom instructions- 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
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.