How It Works
Quick Start
How It Works
The agent forwardsuser_id and agent_id (auto-generated) to the knowledge backend. Vector stores combine filters with $and when multiple scopes are set.
| Scope | Source | Purpose |
|---|---|---|
user_id | MemoryConfig(user_id=…) | Per-user isolation |
agent_id | agent.agent_id (auto) | Per-agent isolation |
run_id | retrieve(…, run_id=…) or store metadata | Per-session isolation |
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
user_id | str | "praison" | User scope on MemoryConfig |
agent_id | str | auto UUID | Agent scope (read-only property) |
run_id | str | None | Session scope on retrieve/store |
Best Practices
Set user_id for tenant isolation
Set user_id for tenant isolation
Use
memory=MemoryConfig(user_id=customer_id) in SaaS apps — each customer’s retrieval stays separate.Pass run_id for ephemeral sessions
Pass run_id for ephemeral sessions
Scope temporary conversation context with
agent.retrieve(query, run_id=session_id).Pick the backend for your scoping needs
Pick the backend for your scoping needs
mem0 enforces scope at ingest; ChromaDB filters at query time with combined
$and clauses.Use consistent identifier naming
Use consistent identifier naming
Prefer readable IDs like
customer_alice_123 over opaque tokens for easier debugging.Related
Knowledge Backends
Vector store backends and scoping support
Knowledge
Configure sources and retrieval

