This is the supported way to use Redis with PraisonAI.
MemoryConfig(backend="redis") is no longer accepted — it raises a ValueError. Always attach Redis through db(state_url=...) as shown below.Quick Start
1
Simple Usage
2
With Configuration
Hybrid setup — SQL for conversations, Redis for state:
How It Works
Redis is a state store — fast key-value access for agent preferences and runtime data. Conversation history usesdatabase_url separately.
Configuration Options
URL formats
Production notes
Redis is single-threaded, so a slow admin command stalls every other client on the same instance. To list many keys, callscan_prefix() instead of keys() — it walks the keyspace with a non-blocking cursor SCAN (batches of 500) so a large read never freezes agents sharing the instance.
Best Practices
Prefer scan_prefix() for large listings
Prefer scan_prefix() for large listings
scan_prefix(prefix) uses a non-blocking SCAN cursor (batch 500), so admin or garbage-collection reads on a large keyspace never stall other agents sharing the Redis instance. Reserve keys(pattern) for small keyspaces.Pair Redis with a SQL conversation backend
Pair Redis with a SQL conversation backend
Use
database_url for chat history and state_url for fast ephemeral state.Set TTL on ephemeral keys
Set TTL on ephemeral keys
Pass
ttl when storing session-scoped data that should expire automatically.Use a key prefix per environment
Use a key prefix per environment
Set
prefix="prod:" vs prefix="staging:" to isolate keys on a shared Redis instance.Enable persistence for durability
Enable persistence for durability
Configure Redis AOF or RDB snapshots if state must survive Redis restarts.
Related
MongoDB State Store
Document-based state with flexible schemas
Database Persistence
Overview of conversation and state backends

