Storage Backends
PraisonAI provides pluggable storage backends for training data, session state, and general persistence. Switch between file-based and database storage without changing your application code.Supported Backends
Quick Start
Any Component with Any Backend
All storage components support pluggable backends. Create a backend once and use it with any component:FileBackend
JSON file-based storage. Each key becomes a separate.json file.
- Zero dependencies (uses built-in
json) - Thread-safe with atomic writes
- Human-readable files
- Easy debugging and inspection
SQLiteBackend
SQLite database storage. All data in a single.db file.
- Zero dependencies (uses built-in
sqlite3) - ACID transactions
- Better concurrent access
- Faster for large datasets
- Single file deployment
Using with Training Storage
TrainingStorage is a context manager — use with to close the backend deterministically.
Using
with (or calling .close() explicitly) releases the underlying SQLite or Redis
connection so the file can be deleted or reopened immediately — essential on Windows, and
best practice for long-running processes. On backends without an open resource (e.g.
FileBackend) .close() is a safe no-op.SQLiteBackend (or RedisBackend) directly — for example via
list_sessions_from_backend(SQLiteBackend(db_path=db)) — close the backend
yourself, or wrap the call in try / finally. TrainingStorage’s context
manager only closes backends it owns.
Using with Learn Stores
Async Support
For async applications, useAsyncBaseJSONStore:
Custom Backends
ImplementStorageBackendProtocol for custom backends:
Protocol Reference
RedisBackend
Redis-based storage for high-speed caching and ephemeral data.- Sub-millisecond latency
- Built-in TTL support
- Automatic key prefixing
- Requires
redispackage:pip install redis
Using with RunHistory (Recipe History)
Store recipe run history with pluggable backends:Using with SessionManager (Session State)
Persist CLI session state with different backends:Using with MCPToolIndex (Tool Index)
Store MCP tool schemas with pluggable backends:Choosing a Backend
Backend Comparison
Related
Database Overview
All supported databases
Memory Storage
Agent memory persistence
Training
Agent training with storage
Session Resume
Continue conversations

