Redis

Use Redis for agent session storage and persistence.

Kern supports using Redis as a database with the RedisDb class.

Usage

Run Redis

Install docker desktop and run Redis on port 6379 using:

1docker run -d \
2 --name my-redis \
3 -p 6379:6379 \
4 redis
1from kern.agent import Agent
2from kern.db.redis import RedisDb
3
4# Initialize Redis db (use the right db_url for your setup)
5db = RedisDb(db_url="redis://localhost:6379")
6
7# Create agent with Redis db
8agent = Agent(db=db)

Params

ParameterTypeDefaultDescription
idOptional[str]-The ID of the database instance. UUID by default.
redis_clientOptional[Redis]-Redis client instance to use. If not provided a new client will be created.
db_urlOptional[str]-Redis connection URL (e.g., "redis://localhost:6379/0" or "rediss://user:pass@host:port/db")
db_prefixstr"kern"Prefix for all Redis keys.
expireOptional[int]-TTL for Redis keys in seconds.
session_tableOptional[str]-Name of the table to store sessions.
memory_tableOptional[str]-Name of the table to store memories.
metrics_tableOptional[str]-Name of the table to store metrics.
eval_tableOptional[str]-Name of the table to store evaluation runs.
knowledge_tableOptional[str]-Name of the table to store knowledge documents.
traces_tableOptional[str]-Name of the table to store traces.
spans_tableOptional[str]-Name of the table to store spans.