Skip to main content
Redis stores agent state in memory for sub-millisecond access — pair it with a SQL backend for conversation history.
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.
The user updates session state; Redis serves fast reads while SQL can hold conversation history.

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 uses database_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, call scan_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

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.
Use database_url for chat history and state_url for fast ephemeral state.
Pass ttl when storing session-scoped data that should expire automatically.
Set prefix="prod:" vs prefix="staging:" to isolate keys on a shared Redis instance.
Configure Redis AOF or RDB snapshots if state must survive Redis restarts.

MongoDB State Store

Document-based state with flexible schemas

Database Persistence

Overview of conversation and state backends