This page has been superseded by Distributed Storage — Redis. Content below is kept for reference.
Redis State Store
agentscope-extensions-redis persists AgentScope agent state in Redis. The unified RedisClientAdapter abstracts over Jedis, Lettuce, and Redisson, covering Standalone, Cluster, and Sentinel deployment modes.
Add the dependency
Quickstart (Lettuce, standalone)
Wiring each client
Jedis
Lettuce cluster
Redisson
Redisson also supportsuseClusterServers()/useSentinelServers()/useMasterSlaveServers(); pass the resultingRedissonClienttoredissonClient(...).
Custom key prefix
By default, all keys look likeagentscope:session:{userSegment}/{sessionId}:... (where userSegment is the userId, or __anon__ for anonymous sessions). When several projects share the same Redis, override it:
Key layout
The(userId, sessionId) pair is packed into a single slot id {userSegment}/{sessionId} (userSegment = userId, or __anon__ when userId is null).
The
_keys index makes delete(userId, sessionId) and exists(userId, sessionId) O(1) without needing KEYS *.
Wire into an agent
RuntimeContext:
Custom adapter
If you target a Redis-compatible store (KeyDB, Tair, …), implementRedisClientAdapter and inject it via clientAdapter(...):
Builder reference
The client setters are mutually exclusive — set exactly one.