- Platform
- Open Source
- Remembers user goals across sessions
- Recalls past workouts and progress
- Adapts its personality based on user preferences
- Handles both short-term context (today’s chat) and long-term memory (months of history)
The Basic Loop with Memory
Max wants to train for a marathon. He starts chatting with Ray, an AI running coach.- Platform
- Open Source
Ray remembers Max’s goal across sessions. The app restarted, but the memory persisted. This is the core pattern: retrieve memories, pass them as context, store new exchanges.
Organizing Memory by Type
Separating Temporary from Permanent
Max mentions his knee hurts. That’s different from his marathon goal - one is temporary, the other is long-term.- Platform
- Open Source
Categories vs Metadata:Now when you add memories, Mem0 automatically assigns the appropriate categories:Mem0 reads the content and intelligently picks which categories apply. You define the palette, it handles the tagging.Important: You cannot force specific categories. Mem0’s platform decides which categories are relevant based on content. If you need to force-tag something, use
- Categories: AI-assigned by Mem0 based on content (you can’t force them)
- Metadata: Manually set by you for forced tagging
Categories vs Metadata: Categories are AI-assigned by Mem0 based on content semantics. You define the palette, Mem0 picks which ones apply. If you need guaranteed tagging, use
metadata instead.metadata instead:Filtering by Category
Retrieve just constraints for workout planning:- Platform
- Open Source
Filtering What Gets Stored
The Problem
Run the basic loop for a week and check what’s stored:- Platform
- Open Source
Custom Instructions
- Platform
- Open Source
Tell Mem0 what matters:
- Platform
- Open Source
Expected output: Only 2 memories stored—the marathon goal and trail preference. The greeting “hey how’s it going” was filtered out automatically. Custom instructions are working.
Agent Memory for Personality
Why Agents Need Memory Too
Max prefers direct feedback, not motivational fluff. Ray needs to remember how to communicate - that’s agent memory, separate from user memory. Store agent personality:- Platform
- Open Source
- Platform
- Open Source
Expected behavior: Ray’s responses are now data-driven and direct. The agent memory stored the coaching style preference, so future responses adapt automatically without Max having to repeat his preference.
Managing Short-Term Context
When to Store in Mem0
Don’t send every single message to Mem0. Keep recent context in memory, let Mem0 handle the important long-term facts.- Platform
- Open Source
Time-Bound Memories
Auto-Expiring Facts
Max tweaks his ankle. It’ll heal in two weeks - the memory should expire too.- Platform
- Open Source
Putting It All Together
Here’s the Mem0 setup combining everything:- Platform
- Open Source
- Platform
- Open Source
- Platform
- Open Source
- Platform
- Open Source
Common Production Patterns
Episodic Stories with run_id
Training for Boston is different from training for New York. Separate the memory threads:- Platform
- Open Source
Importing Historical Data
Max has 6 months of training logs to backfill:- Platform
- Open Source
Handling Contradictions
Max changes his goal from sub-4 to sub-3:45:- Platform
- Open Source
Multiple Agents
Max works with Ray for running and Jordan for strength training:- Platform
- Open Source
Filtering by Date
Prioritize recent training over old data:- Platform
- Open Source
Metadata Tagging
Tag workouts by type:- Platform
- Open Source
Pruning Old Memories
Delete irrelevant memories:- Platform
- Open Source
What You Built
A companion that:- Persists across sessions - Mem0 storage
- Filters noise - custom instructions
- Organizes by type - categories
- Adapts personality -
agent_id - Stays fast - short-term buffer
- Handles temporal facts - expiration
- Scales to production - batching, metadata, pruning
Production Checklist
Before launching:- Set custom instructions for your domain
- Define 2-3 categories (goals, constraints, preferences)
- Add expiration strategy for time-bound facts
- Implement error handling for API calls
- Monitor memory quality (Mem0 dashboard or
get_all/ Qdrant when local) - Clear test data from production project
Partition Memories by Entity
Keep companions from leaking context by combining user, agent, and session scopes.
Tag Support Memories
Organize customer context to keep assistants responsive at scale.