RedisDb
Store AgentOS sessions, memory, knowledge, evals, and traces in Redis.
RedisDb implements the Db interface with Redis key-value storage for Agent, Team, and Workflow sessions, memories, knowledge, metrics, evals, traces, and spans. Records are stored as JSON strings under a configurable key prefix, with optional TTL expiry.
| Parameter | Type | Default | Description |
|---|---|---|---|
id | Optional[str] | - | Database ID. Derived deterministically from the URL (or client representation) and key prefix when omitted. |
redis_client | Optional[Union[Redis, RedisCluster]] | - | Redis client instance to use. If not provided a new client will be created from db_url. Required for Redis Cluster connections. |
db_url | Optional[str] | - | Redis connection URL (e.g., "redis://localhost:6379/0" or "rediss://user:pass@host:port/db"). Supports single-node Redis only. |
db_prefix | str | "agno" | Prefix for all Redis keys. |
expire | Optional[int] | - | TTL for Redis keys in seconds. |
session_table | Optional[str] | - | Name of the table to store sessions. |
runs_table | Optional[str] | - | Name of the table to store runs. |
memory_table | Optional[str] | - | Name of the table to store memories. |
metrics_table | Optional[str] | - | Name of the table to store metrics. |
eval_table | Optional[str] | - | Name of the table to store evaluation runs. |
knowledge_table | Optional[str] | - | Name of the table to store knowledge documents. |
traces_table | Optional[str] | - | Name of the table to store traces. |
spans_table | Optional[str] | - | Name of the table to store spans. |
Methods
upsert_sessions
Upsert multiple sessions in one method call.
Parameters:
sessions(List[Session]): List of sessions to upsertdeserialize(Optional[bool]): Whether to deserialize the sessions. Defaults toTruepreserve_updated_at(bool): Request preservation of the sessions' existingupdated_attimestamps; see adapter limitations below. Defaults toFalse
Returns: List[Union[Session, Dict[str, Any]]]
upsert_memories
Upsert multiple memories in one method call.
Parameters:
memories(List[UserMemory]): List of memories to upsertdeserialize(Optional[bool]): Whether to deserialize the memories. Defaults toTruepreserve_updated_at(bool): Request preservation of the memories' existingupdated_attimestamps; see adapter limitations below. Defaults toFalse
Returns: List[Union[UserMemory, Dict[str, Any]]]
Timestamp preservation by adapter
JsonDb, GcsJsonDb, FirestoreDb, RedisDb, DynamoDb, and InMemoryDb accept preserve_updated_at but do not forward it to their individual upserts. Their bulk methods replace timestamps even when it is True.
PostgresDb, SingleStoreDb, and ValkeyDb honor the flag. MySQLDb, SqliteDb, and MongoDb honor it on their optimized bulk path; their per-record fallback paths do not forward it. Verify timestamps when a migration depends on preserving them.