Memory Storage
Database backends for agent memory and state persistence
Memory Storage
PraisonAI supports 22+ database backends for memory persistence. Choose the right one for your use case.
Storage Categories
Conversation Stores
Store conversation history and chat context. Best for session continuity.
Production-ready relational DB
MySQLPopular relational DB
SQLiteZero-config local storage
JSONSimple file-based storage
SupabaseManaged Postgres
NeonServerless Postgres
State Stores
Store agent state, checkpoints, and runtime data. Best for complex workflows.
High-speed caching
MongoDBDocument store
DynamoDBAWS managed
FirestoreGoogle Cloud
UpstashServerless Redis
DakeraDecay-weighted vector recall
Quick Setup
from praisonaiagents import Agent
# SQLite (zero-config, default)
agent = Agent(memory=True)
# SQLite via preset
agent = Agent(memory="sqlite")
# MongoDB via URL scheme
agent = Agent(
memory={
"db": "mongodb://localhost:27017/mydb",
"session_id": "user-123"
}
)Choosing a Database
| Use Case | Recommended | Why |
|---|---|---|
| Local development | SQLite/JSON | Zero config |
| Production web app | PostgreSQL | Reliable, scalable |
| High-speed caching | Redis | Sub-ms latency |
| Serverless | Neon/Upstash | No server management |
| AWS infrastructure | DynamoDB | Native integration |
| Decay-weighted recall across sessions | Dakera | Importance-scored, time-decayed memory server |
For self-hosted decay-weighted vector memory with importance scoring and tiered recall, see Dakera Memory.
Storage Backends
For training data, sessions, and general persistence, PraisonAI provides pluggable storage backends:
| Backend | Dependencies | Best For |
|---|---|---|
| FileBackend | None | Development, debugging |
| SQLiteBackend | None | Production, concurrent access |
| RedisBackend | redis | High-speed caching, distributed |
from praisonaiagents.storage import FileBackend, SQLiteBackend, RedisBackend
# File-based (default)
file_backend = FileBackend(storage_dir="~/.praisonai/data")
# SQLite (recommended for production)
sqlite_backend = SQLiteBackend(db_path="~/.praisonai/data.db")
# Redis (for distributed systems)
redis_backend = RedisBackend(url="redis://localhost:6379", prefix="praison:")Durability
FileMemory writes are atomic. Every _write_json writes into a same-directory temp file, fsyncs it, then os.replaces it into place — a crash mid-write (SIGKILL, power loss, OOM) can never leave the memory file empty or half-written. Same guarantee on POSIX and Windows.
flock-based mutual exclusion still applies on Unix so concurrent writers see a consistent view (Windows has noflock; atomicity ofos.replacestill holds).- Temp files use a
.<name>.…tmpprefix inside the memory directory. A crash between temp creation and rename leaves the temp file behind; it is safe to delete manually and is otherwise harmless.
See Storage Backends for detailed usage with all components.