What this thread does
Do first: run history = list(graph.get_state_history(config)).
When you need it
Use a fork to explore another path from a past checkpoint with changed state. Nodes before that checkpoint retain their saved results; later nodes execute again.
Steps
1. Start from the page's already-run generate_topic → write_joke graph with an InMemorySaver checkpointer and its config. Find the checkpoint just before write_joke:
history = list(graph.get_state_history(config))
before_joke = next(s for s in history if s.next == ("write_joke",))
2. Change the topic at that checkpoint and keep the returned branch configuration:
fork_config = graph.update_state(
before_joke.config,
values={"topic": "chickens"},
)
3. Continue the branch with no new input:
fork_result = graph.invoke(None, fork_config)
print(fork_result["joke"])
Check it worked
The page’s print statement produces a joke about chickens rather than the earlier socks topic. It identifies write_joke as the node that runs again.
Limits
The page does not name a version. update_state creates a new checkpoint and preserves the original history; it does not roll back a thread. Downstream model calls, API requests, and interrupts execute again and may differ. Parallel updates can require explicit as_node when the writer cannot be inferred.
Not for: diagnosing inherited Command updates during time travel; see langgraph-time-travel-reapplies-command-update.
Sources
- Use time-travel, LangGraph documentation, read 2026-11-24: "The original execution history remains intact."
Checked
2026-11-24; read <https://docs.langchain.com/oss/python/langgraph/use-time-travel.md>; no command was run.
Started from a post by @LangGraph, packaged by the editor. Original post