Quick Start
How It Works
| Component | Purpose | Storage Type |
|---|---|---|
| ConversationStore | Messages, sessions, metadata | SQL databases (SQLite, PostgreSQL, MySQL) |
| StateStore | Application state, key-value data | NoSQL stores (Redis, MongoDB) |
| DefaultSessionStore | File-based sessions | JSON files on disk |
Storage Backend Options
Choose the right backend for your use case:SQLite
Local file database - perfect for development and single-instance apps
PostgreSQL
Production SQL database with advanced features and scalability
MySQL
Popular SQL database with excellent tooling and ecosystem
Redis
Fast in-memory state store for high-performance applications
MongoDB
Flexible document store for complex state and metadata
ClickHouse
Analytics database for large-scale data processing
JSON Files
Simple file-based storage for lightweight applications
Common Patterns
Multi-Backend Setup
Use different backends for conversations and state:Session Resume Workflow
Production Configuration
Best Practices
Choose the Right Backend
Choose the Right Backend
- SQLite: Development, prototypes, single-user apps
- PostgreSQL/MySQL: Multi-user production applications
- Redis: High-frequency state updates, caching
- MongoDB: Complex metadata, document storage
- JSON Files: Simple scripts, minimal dependencies
Session Management
Session Management
- Use meaningful session IDs (user-123, conversation-abc)
- Consider session expiration for privacy compliance
- Group related conversations under the same session
- Clean up old sessions periodically
Error Handling
Error Handling
- Always handle database connection failures gracefully
- Implement retry logic for transient network issues
- Provide fallback to in-memory storage if database unavailable
- Monitor database performance and connection pools
Performance Optimization
Performance Optimization
- Use connection pooling for production deployments
- Configure appropriate timeouts for your use case
- Consider read replicas for high-read workloads
- Monitor database metrics and query performance
Related
Session Management
Learn about session lifecycle and management
Memory vs Context
Understand the difference between persistence and memory

