Skip to content

Commit cbf4139

Browse files
committed
test(langgraph-ts): fix prepare-regenerate-stream fixture to match newest-first getHistory order
`threads.getHistory` returns checkpoints newest-first; `getCheckpointByMessage` reverses to walk oldest-first and finds the first checkpoint containing the target message. The previous fixture ordered ck-old before ck-new, so after reverse the search found ck-new (which had both u1 and a1), saw `messagesAfter` non-empty, and recursed on the parent — but the mock returned the same list every time, so the search never terminated and the worker timed out. Swap to newest-first so the reversed walk lands on ck-old (only u1, no messagesAfter) and returns immediately.
1 parent 7109b79 commit cbf4139

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

integrations/langgraph/typescript/src/prepare-regenerate-stream.test.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,36 @@ function makeThreadStream() {
4848

4949
function makeConfig(opts: { useTransformer: boolean }) {
5050
const threadStreams = new Map<string, ReturnType<typeof makeThreadStream>>();
51+
// LangGraph's `threads.getHistory` returns checkpoints newest-first.
52+
// `getCheckpointByMessage` reverses to walk oldest→newest and finds
53+
// the FIRST checkpoint containing the target message — that's the
54+
// one we regenerate from. Order this fixture the same way.
5155
const history = [
5256
{
53-
// Older checkpoint — includes the message we'll regenerate from.
57+
// Newer checkpoint with a follow-up assistant message.
5458
values: {
5559
messages: [
5660
{ id: "u1", type: "human", content: "first" } as LangGraphMessage,
61+
{ id: "a1", type: "ai", content: "answer" } as LangGraphMessage,
5762
],
5863
},
59-
checkpoint: { checkpoint_id: "ck-old" },
60-
parent_checkpoint: null,
61-
next: ["model"],
64+
checkpoint: { checkpoint_id: "ck-new" },
65+
parent_checkpoint: { checkpoint_id: "ck-old", checkpoint_ns: "" },
66+
next: [],
6267
tasks: [],
6368
metadata: {},
6469
},
6570
{
66-
// Newer checkpoint with a follow-up assistant message.
71+
// Older checkpoint — contains only the message we'll regenerate
72+
// from; no `messagesAfter`, so the search terminates here.
6773
values: {
6874
messages: [
6975
{ id: "u1", type: "human", content: "first" } as LangGraphMessage,
70-
{ id: "a1", type: "ai", content: "answer" } as LangGraphMessage,
7176
],
7277
},
73-
checkpoint: { checkpoint_id: "ck-new" },
74-
parent_checkpoint: { checkpoint_id: "ck-old", checkpoint_ns: "" },
75-
next: [],
78+
checkpoint: { checkpoint_id: "ck-old" },
79+
parent_checkpoint: null,
80+
next: ["model"],
7681
tasks: [],
7782
metadata: {},
7883
},

0 commit comments

Comments
 (0)