The only Redis-based checkpoint saver for LangGraph in TypeScript/JavaScript
A Redis checkpoint saver for LangGraph that persists your app state across restarts and scales with your application.
- Only Redis checkpoint saver for LangGraph in TypeScript/JavaScript
- Official LangGraph checkpoint savers are Python-only (SQLite, PostgreSQL)
- Essential for Node.js/TypeScript LangGraph applications
- Redis-powered: Fast read/write operations
- Scales easily: Share state across multiple app instances
- Memory efficient: Redis handles the heavy lifting
- TTL support: Automatic cleanup of old checkpoints
- High availability: Redis clustering and replication support
- Survive restarts: Resume where you left off
- Persistent state: Conversations and workflows persist
- Easy debugging: Check execution history and state
- Fault tolerance: Graceful recovery with checkpoints
- Long conversations with AI agents
- Multi-step workflows that need state persistence
- Distributed systems with shared state
- Applications requiring reliability
npm install checkpoint-redis
import { RedisSaver } from "checkpoint-redis";
import { Redis } from "ioredis";
import { StateGraph } from "@langchain/langgraph";
// Create Redis connection
const redis = new Redis(process.env.REDIS_URL);
// Create checkpoint saver
const checkpointSaver = new RedisSaver({ connection: redis });
// Use with LangGraph
const workflow = new StateGraph({
// ... your graph definition
}).compile({
checkpointer: checkpointSaver
});
// Your workflow now persists state to Redis!
const result = await workflow.invoke(
{ input: "Hello" },
{ configurable: { thread_id: "conversation-123" } }
);
import { RedisSaver } from "checkpoint-redis";
import { Redis } from "ioredis";
// Redis with custom configuration
const redis = new Redis({
host: "localhost",
port: 6379,
password: "your-password",
db: 0,
retryDelayOnFailover: 100,
maxRetriesPerRequest: 3,
});
// Basic checkpoint saver
const checkpointSaver = new RedisSaver({ connection: redis });
// With TTL (checkpoints expire after 1 hour)
const checkpointSaverWithTTL = new RedisSaver({
connection: redis,
ttl: 3600 // 1 hour in seconds
});
// Each conversation gets its own thread
const config1 = { configurable: { thread_id: "user-123" } };
const config2 = { configurable: { thread_id: "user-456" } };
// These run independently with separate state
await workflow.invoke({ input: "Hi" }, config1);
await workflow.invoke({ input: "Hello" }, config2);
// List all checkpoints for a thread
for await (const checkpoint of checkpointSaver.list({
configurable: { thread_id: "user-123" }
})) {
console.log(`Checkpoint: ${checkpoint.checkpoint.id}`);
console.log(`Timestamp: ${checkpoint.checkpoint.ts}`);
}
// Get specific checkpoint
const specific = await checkpointSaver.getTuple({
configurable: {
thread_id: "user-123",
checkpoint_id: "specific-checkpoint-id"
}
});
Solution | Language | Storage | Production Ready | Performance | Setup |
---|---|---|---|---|---|
checkpoint-redis | TypeScript | Redis | ✅ | ⚡ High | Easy |
InMemorySaver | TypeScript | Memory | ❌ | ⚡ Fast | Trivial |
SqliteSaver | Python | SQLite | 🐌 Slow | Easy | |
PostgresSaver | Python | PostgreSQL | ✅ | 🚀 Fast | Complex |
- Node.js >= 18
- Redis server
@langchain/core
>= 0.2.31@langchain/langgraph-checkpoint
^0.0.6ioredis
>= 5.0.0
new RedisSaver({ connection: Redis, ttl?: number }, serde?: SerializerProtocol)
Parameters:
connection
- Redis connection instancettl
- Optional TTL in seconds for checkpoint keys (default: no expiration)
put(config, checkpoint, metadata)
- Save a checkpointgetTuple(config)
- Retrieve a checkpointputWrites(config, writes, taskId)
- Save pending writeslist(config, options?)
- List checkpoints with optional filtering
See checkpoint-redis
in action with our interactive chat demo:
git clone https://github.com/levivoelz/checkpoint-redis.git
cd checkpoint-redis/demo
docker-compose up --build
# Open http://localhost:3000
The demo features:
- AI-powered chat with Ollama integration
- Real-time checkpoint logging with detailed sidebar
- TTL toggle for checkpoint expiration
- Model selection and live stats
- Copy functionality for debugging
Upgrading from v0.1.x? See our migration guide for details on new features and improvements.
Contributions welcome! Please see our contributing guidelines.
Planned improvements for checkpoint-redis
:
- Error Handling - Better validation and error messages
- Performance - Batch operations and memory optimization
- Code Quality - Fix bugs and improve consistency
- API Improvements - More configuration options and better types
See the detailed roadmap for the complete list.
MIT © Levi Voelz