Quick Start
How It Works
| Store | Purpose | Example backends |
|---|---|---|
| Conversation | Chat history, tool calls | PostgreSQL, MySQL, SQLite, Supabase, SurrealDB |
| State | Runs, traces, metadata | Redis, MongoDB, DynamoDB, Firestore |
| Knowledge | Vectors / RAG | Qdrant, ChromaDB, Pinecone, Weaviate |
session_id. Each turn writes user and agent messages automatically — no manual save calls.
Configuration Options
Pass adb() instance via memory= (or MemoryConfig(db=…, session_id=…) for explicit sessions).
| Parameter | Description |
|---|---|
database_url | Conversation store URL |
state_url | State / run history store |
knowledge_url | Vector or knowledge store |
Environment variables
Database backends require the
praisonai wrapper (pip install praisonai). The core SDK defines DbAdapter; implementations live in praisonai.db.Default session ID
If you omitsession_id, PraisonAI generates a per-hour ID (UTC):
Docker (local development)
CLI commands
Async-Safe Initialisation
TheDatabaseAdapter’s async callbacks (on_agent_start, on_user_message, on_agent_message, on_tool_call, on_agent_end) never block the event loop. Store construction runs off-loop via asyncio.to_thread, so FastAPI handlers, Jupyter notebooks, and async test suites all work without stalls on cold startup.
Transient Failure Handling
When a database is temporarily unavailable (bad config, network blip, cloud auth glitch), the adapter records the failure and waits before re-attempting. This prevents hammering a down backend on every agent callback while still recovering automatically once the backend is back. The cool-down period is configurable viainit_retry_cooldown (default 30 seconds):
| Parameter | Type | Default | Description |
|---|---|---|---|
init_retry_cooldown | float | 30.0 | Seconds to wait before retrying a failed store init |
_ainit_stores()), the adapter pauses for init_retry_cooldown seconds before re-running store construction on the next callback. Persistence resumes automatically once the backend becomes reachable — no process restart needed.
Best Practices
Use explicit session_id for continuity
Use explicit session_id for continuity
Without
session_id, PraisonAI generates a per-hour ID. Set MemoryConfig(session_id=…) when users return to the same thread.Read credentials from the environment
Read credentials from the environment
Never hardcode database URLs — use
os.getenv("PRAISON_CONVERSATION_URL").Run doctor before production
Run doctor before production
praisonai persistence doctor validates connectivity for conversation, state, and knowledge stores.Separate stores by concern
Separate stores by concern
Conversation history, run traces, and vectors scale differently — configure
database_url, state_url, and knowledge_url independently.Related
Run History
Query persisted runs and traces
Session Persistence
JSON file sessions without a database

