How It Works
Quick Start
1
Simple Usage
Set
user_id via memory config — the agent passes it to every knowledge search:2
With Configuration
Combine scopes for multi-tenant SaaS — pass
run_id on retrieve for session-specific context: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.
Configuration Options
Backends: ChromaDB supports all scopes; mem0 requires at least one scope identifier.
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

