Skip to content

chore: more back pressure#7499

Draft
William FH (hinthornw) wants to merge 4 commits into
mainfrom
wfh/bp
Draft

chore: more back pressure#7499
William FH (hinthornw) wants to merge 4 commits into
mainfrom
wfh/bp

Conversation

@hinthornw

@hinthornw William FH (hinthornw) commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some questions / comments

Comment on lines +903 to +904
def _put_checkpoint(self, metadata: CheckpointMetadata) -> None:
raise NotImplementedError

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we worried this will break for folks?

Comment on lines +959 to +963
if self.durability == "exit" and (
not self.is_nested
or exc_value is not None
or all(NS_END not in part for part in self.checkpoint_ns)
):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add the comments bacK?

self._dispatch_checkpoint_request(request)

def after_tick(self) -> None:
if request := self._after_tick():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pattern feels confusing to me

Comment on lines +1393 to +1399
if self.durability == "exit" and (
not self.is_nested
or exc_value is not None
or all(NS_END not in part for part in self.checkpoint_ns)
):
if request := self._prepare_checkpoint(self.checkpoint_metadata):
await self._dispatch_checkpoint_request(request)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug that we didn't have this before?

Christian Bromann (christian-bromann) added a commit to langchain-ai/langgraphjs that referenced this pull request Jun 10, 2026
## Summary

Ports Python time-travel fixes
([#7038](langchain-ai/langgraph#7038),
[#7115](langchain-ai/langgraph#7115),
[#7498](langchain-ai/langgraph#7498),
[#7499](langchain-ai/langgraph#7499)) into
`@langchain/langgraph` so replay/fork behave correctly with interrupts
and nested subgraphs.

- **Stale `RESUME` on replay** — Replaying from a checkpoint before an
interrupt no longer consumes cached resume writes; interrupts re-fire
with the correct payload.
- **Subgraph checkpoint loading on time travel** — Introduces
`ReplayState` (`CONFIG_KEY_REPLAY_STATE`) so nested subgraphs load the
checkpoint that existed at the replay point on first visit, then resume
normal head loading within the same run.
- **Parent fork checkpoints on replay** — Time travel runs through
`PregelLoop._first()` (not `stream()` delegation on the parent
`Pregel`), creating an eager `source: "fork"` checkpoint and propagating
`ReplayState` to subgraphs.
- **Direct-to-subgraph time travel** — `getState()` subgraph delegation
is guarded with `CONFIG_KEY_READ`; direct subgraph configs strip stale
`RESUME` writes and prefer explicit `checkpoint_id` over
`checkpoint_map` when both are set.
- **Streaming** — Fixes subgraph interrupt namespace when streaming with
`subgraphs: true` (empty `checkpoint_ns` no longer becomes `[""]`;
parent emits interrupts under the deepest `checkpoint_map` namespace).

Closes #2325 (supersedes the earlier partial port).

### Implementation notes

| Area | Change |
|------|--------|
| `pregel/replay.ts` | New `ReplayState` class (mirrors Python) |
| `pregel/loop.ts` | Replay/time-travel detection, fork creation,
`RESUME` stripping, `ReplayState` wiring, stream namespace helpers |
| `pregel/index.ts` | `getState` subgraph delegation guard only (removed
`stream()` bypass that skipped parent fork creation) |
| Tests | `time_travel.test.ts` (14), `time_travel_extended.test.ts`
(33), shared `time_travel_helpers.ts`, Vitest matchers `toBeInterrupted`
/ `toHaveInterruptValue` |

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants