This tutorial builds on Customize state.
1. Rewind your graph
Rewind your graph by fetching a checkpoint using the graph’sgetStateHistory
method. You can then resume execution at this previous point in time.
2. Add steps
Add steps to your graph. Every step will be checkpointed in its state history:3. Replay the full state history
Now that you have added steps to the chatbot, you canreplay
the full state history to see everything that occurred.
Resume from a checkpoint
Resume from thetoReplay
state, which is after a specific node in one of the graph invocations. Resuming from this point will call the next scheduled node.
Resume from the toReplay
state, which is after the chatbot
node in one of the graph invocations. Resuming from this point will call the next scheduled node.
4. Load a state from a moment-in-time
The checkpoint’stoReplay.config
contains a checkpoint_id
timestamp. Providing this checkpoint_id
value tells LangGraph’s checkpointer to load the state from that moment in time.
tools
node. You can tell this is the case since the first value printed above is the response from our search engine tool.
Congratulations! You’ve now used time-travel checkpoint traversal in LangGraph. Being able to rewind and explore alternative paths opens up a world of possibilities for debugging, experimentation, and interactive applications.
Learn more
Take your LangGraph journey further by exploring deployment and advanced features:- LangGraph Server quickstart: Launch a LangGraph server locally and interact with it using the REST API and LangGraph Studio Web UI.
- LangGraph Platform quickstart: Deploy your LangGraph app using LangGraph Platform.