- 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.
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 required1. 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.