Quick Start
1
Simple Usage
2
With Configuration
Use
MongoDBStateStore directly for collection and database control:How It Works
MongoDB is a state store — it holds key-value agent state, not full conversation history. Pair it with a SQL conversation backend when you need both.Configuration Options
URL formats
create_state_store("async_mongodb", ...).
Best Practices
Pair with a conversation backend
Pair with a conversation backend
Use
database_url for chat history and state_url for fast agent state — MongoDB handles state only.Set TTL for ephemeral data
Set TTL for ephemeral data
Pass
ttl on set() for session-scoped preferences that should expire automatically.Use replica sets in production
Use replica sets in production
Append
replicaSet= to the URL for high availability.Choose collection names per app
Choose collection names per app
Set
collection="prod_state" vs collection="staging_state" to isolate environments on one cluster.Related
Redis State Store
In-memory state for sub-millisecond access
Database Persistence
Overview of conversation and state backends

