fix: time travel when going back to interrupt node#7498
Open
Sydney Runkle (sydney-runkle) wants to merge 4 commits intomainfrom
Open
fix: time travel when going back to interrupt node#7498Sydney Runkle (sydney-runkle) wants to merge 4 commits intomainfrom
Sydney Runkle (sydney-runkle) wants to merge 4 commits intomainfrom
Conversation
William FH (hinthornw)
approved these changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Create fork checkpoint on subgraph time travel
Problem
When time-traveling to a subgraph checkpoint that has an interrupt, and then resuming, the resume would load the wrong state — it would pick up the original execution's latest checkpoint instead of the time-traveled one.
This happened because replaying from a subgraph checkpoint never created a new parent checkpoint. If the replay hit an interrupt before
after_tick()ran, no checkpoint was written at all, so the parent's "latest" checkpoint was still the old one from the original execution.Fix
When the loop detects a time-travel replay (not an
update_statefork), it now eagerly writes a fork checkpoint at the start of the tick. This ensures:Command(resume=...)calls find the correct checkpointINTERRUPTpending writes from the old checkpoint are cleared (they reference old task IDs)Additionally, the subgraph replay logic now uses the parent checkpoint ID (from
prev_checkpoint_config) when resolving subgraph checkpoints during time-travel, matching the existing behavior forupdate_stateforks.Checkpoint flow diagrams
Before fix: time travel leaves no fork
After fix: time travel creates a fork
Manual fork via
update_state(unchanged)Changes
libs/langgraph/langgraph/pregel/_loop.py:is_time_travelingflag from the existing replay detection logic for reusesource="fork") eagerly at the start of a time-travel tick, before execution beginsINTERRUPTpending writes when creating the fork (they reference old task IDs that won't match the new checkpoint)source in ("update", "fork")instead of a separateis_time_travelingcondition, since the new fork checkpoint now hassource="fork"libs/langgraph/tests/test_time_travel.pyandtest_time_travel_async.py: Added 4 new test cases (sync + async):test_replay_from_before_interrupt_then_resume— replays from a checkpoint before an interrupt, resumes with a new answer, and verifies the full checkpoint history (source, next, values) at each stagetest_subgraph_time_travel_resume_from_first_interrupt— time-travels to a subgraph's first interrupt, resumes both interrupts with new answers, and verifies the fork creates a new branch while preserving the originaltest_subgraph_time_travel_resume_from_second_interrupt— time-travels to a subgraph's second interrupt, resumes with a new answer, and verifies the first interrupt's original answer is preservedtest_subgraph_time_travel_checkpoint_pattern— verifies the fork checkpoint branches from the correct replay point and that the full checkpoint tree is correct after resumelibs/langgraph/tests/test_pregel.py/test_pregel_async.py: Updated existingtest_weather_subgraph_stateto account for the new fork checkpoint appearing in history (history length increases by 1)