Quick Start
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.| Feature | Description |
|---|---|
| Document storage | Nested objects and arrays without a fixed schema |
| TTL index | Automatic expiry via expires_at field |
| Hash operations | hget, hset, hgetall for structured state |
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
url | str | "mongodb://localhost:27017" | MongoDB connection URL |
database | str | "praisonai" | Database name |
collection | str | "state" | Collection for state documents |
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

