Overview
Checkpointing enables LangGraph to persist state across invocations, recover from failures, and provide time-travel debugging. It’s the foundation for long-running agents, human-in-the-loop workflows, and conversational memory.What is a Checkpoint?
A checkpoint is a snapshot of your graph’s state at a specific point in time:Basic Setup
In-Memory Checkpointing
For development and testing:Using Thread IDs
Thread IDs group related invocations:The
thread_id is the primary key for storing and retrieving checkpoints. Use unique IDs for independent conversations or sessions.Persistent Checkpointers
PostgreSQL
For production use with PostgreSQL:SQLite
For single-file persistence:Async Checkpointers
For async graphs:State Management
Getting Current State
Retrieve the latest state for a thread:State History
Access historical checkpoints:Checkpoint Metadata
Each checkpoint includes metadata:Time-Travel and Replay
Resume from Any Checkpoint
Replay from a historical state:Fork Conversations
Create alternate timelines:Manual State Updates
Modify state externally:Bulk Updates
Apply multiple updates in sequence:Subgraph Checkpoints
Subgraphs can have independent checkpointers:Interrupt and Resume
Pause execution and resume later:Custom Checkpointers
Implement your own storage backend:Also implement async versions (
aget_tuple, aput, etc.) for async graphs.Checkpoint Lifecycle
Thread Management
Deleting Threads
Copying Threads
Pruning Checkpoints
Best Practices
Thread ID Strategy
Thread ID Strategy
- Use UUID for one-off workflows
- Use user_id + session_id for conversations
- Include version in ID for schema changes
- Document your thread ID format
Performance
Performance
- Use connection pools for database checkpointers
- Implement async checkpointers for async graphs
- Prune old checkpoints regularly
- Index thread_id and timestamp columns
- Consider checkpoint size (minimize state bloat)
Reliability
Reliability
- Always use persistent checkpointers in production
- Test checkpoint recovery scenarios
- Monitor checkpoint save/load latency
- Handle checkpointer failures gracefully
- Back up checkpoint databases
Security
Security
- Encrypt sensitive data in checkpoints
- Implement access control on thread IDs
- Audit checkpoint access
- Comply with data retention policies
Troubleshooting
Checkpoint not found
Checkpoint not found
- Verify thread_id is correct
- Check if checkpoint was ever created
- Ensure checkpointer is connected
- Look for deletion/pruning events
State not persisting
State not persisting
- Confirm checkpointer is passed to compile()
- Verify thread_id in config
- Check for database connection issues
- Review error logs for write failures
Performance issues
Performance issues
- Reduce state size (avoid large objects)
- Use indexed queries for history
- Enable connection pooling
- Consider checkpoint compression
Next Steps
Human-in-the-Loop
Use checkpointing with interrupts for human oversight
Streaming
Stream checkpoints in real-time as they’re created