- Understand reasoning: Analyze the steps that led to a successful result.
- Debug mistakes: Identify where and why errors occurred.
- Explore alternatives: Test different paths to uncover better solutions.
- Run the graph with initial inputs using
invokeorstreammethods. - Identify a checkpoint in an existing thread: Use the
get_state_historymethod to retrieve the execution history for a specificthread_idand locate the desiredcheckpoint_id. Alternatively, set an interrupt before the node(s) where you want execution to pause. You can then find the most recent checkpoint recorded up to that interrupt. - Update the graph state (optional): Use the
update_statemethod to modify the graph’s state at the checkpoint and resume execution from alternative state. - Resume execution from the checkpoint: Use the
invokeorstreammethods with an input ofNoneand a configuration containing the appropriatethread_idandcheckpoint_id.
For a conceptual overview of time-travel, see Time travel.
In a workflow
This example builds a simple LangGraph workflow that generates a joke topic and writes a joke using an LLM. It demonstrates how to run the graph, retrieve past execution checkpoints, optionally modify the state, and resume execution from a chosen checkpoint to explore alternate outcomes.Setup
First we need to install the packages requiredSign up for LangSmith to quickly spot issues and improve the performance of your LangGraph projects. LangSmith lets you use trace data to debug, test, and monitor your LLM apps built with LangGraph.
1. Run the graph
2. Identify a checkpoint
3. Update the state
update_state will create a new checkpoint. The new checkpoint will be associated with the same thread, but a new checkpoint ID.
4. Resume execution from the checkpoint
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.