Skip to main content

Overview

StateGraph automatically saves execution state at every step, enabling powerful features:
  • 🔄 Resume from failures - Restart where you left off
  • 🕐 Time travel - Access any historical state
  • 🌳 Fork execution - Create alternative timelines
  • 💾 Multi-session - Continue conversations across sessions

Checkpointers

Checkpointers store graph state. Choose based on your needs:

Using MemorySaver

Best for development and testing:

Using SqliteCheckpointer

Best for production with persistence across restarts:
Important: Always use check_same_thread=False when creating SQLite connections for StateGraph. This is required because the graph uses asyncio internally which may execute checkpoint operations on different threads.

Threads

Threads organize independent execution histories. Each thread has its own state and checkpoint history.

Multi-Turn Conversations

Build chatbots that maintain conversation history:
When using checkpointers, you only need to provide new state changes. The graph automatically loads and merges with the previous state.

Multiple Threads

Handle multiple independent conversations:

Time Travel

Access any point in execution history:

Forking Execution

Create alternative timelines by resuming from historical checkpoints:

Getting Current State

Inspect the current state of a thread:

Updating State Manually

Modify state outside of graph execution:
Note on resuming execution:
  • Pass {} (empty dict) to restart the graph from START with the current checkpoint state
  • Pass None to resume from where execution left off - but if the graph already reached END, it just returns the current state without re-executing

Durability Modes

Control when checkpoints are saved:

Next Steps