Redis State Store
Persistent state storage with Redis for production use.
Setup
# Start Redis
docker run -d -p 6379:6379 redisUsage
import { RedisStateStore } from '@ahzan-agentforge/core';
const store = new RedisStateStore({
url: 'redis://localhost:6379',
});RedisStateStoreConfig
interface RedisStateStoreConfig {
url?: string; // Redis connection URL
prefix?: string; // Key prefix (default: 'agentforge:')
ttl?: number; // Key TTL in seconds
}Key Schema
Redis keys follow the pattern:
agentforge:run:{runId} → Serialized RunState (JSON)
agentforge:runs:index → Set of all run IDsProduction Configuration
const store = new RedisStateStore({
url: process.env.REDIS_URL || 'redis://localhost:6379',
prefix: 'myapp:agentforge:',
ttl: 86400 * 7, // 7 days
});
const agent = defineAgent({
name: 'production-agent',
description: 'Production agent with persistent state',
tools: [myTool],
llm,
systemPrompt: '...',
stateStore: store,
});Next Steps
- Checkpoint & Resume — how checkpointing works