Skip to content

Commit 48e9927

Browse files
committed
Revert to default behaviour
1 parent c83cd7d commit 48e9927

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

libs/langgraph/src/pregel/index.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,10 +1247,20 @@ export class Pregel<
12471247
throw new InvalidUpdateError(`Cannot copy a non-existent checkpoint`);
12481248
}
12491249

1250+
const isCopyWithUpdates = (
1251+
values: unknown
1252+
): values is [values: unknown, asNode: string][] => {
1253+
if (!Array.isArray(values)) return false;
1254+
if (values.length === 0) return false;
1255+
return values.every((v) => Array.isArray(v) && v.length === 2);
1256+
};
1257+
12501258
const nextCheckpoint = createCheckpoint(checkpoint, undefined, step);
12511259
const nextConfig = await checkpointer.put(
12521260
saved.parentConfig ??
1253-
patchConfigurable(saved.config, { checkpoint_id: undefined }),
1261+
(isCopyWithUpdates(values)
1262+
? patchConfigurable(saved.config, { checkpoint_id: undefined })
1263+
: saved.config),
12541264
nextCheckpoint,
12551265
{
12561266
source: "fork",
@@ -1261,14 +1271,6 @@ export class Pregel<
12611271
{}
12621272
);
12631273

1264-
const isCopyWithUpdates = (
1265-
values: unknown
1266-
): values is [values: unknown, asNode: string][] => {
1267-
if (!Array.isArray(values)) return false;
1268-
if (values.length === 0) return false;
1269-
return values.every((v) => Array.isArray(v) && v.length === 2);
1270-
};
1271-
12721274
// We want to both clone a checkpoint and update state in one go.
12731275
// Reuse the same task ID if possible.
12741276
if (isCopyWithUpdates(values)) {

0 commit comments

Comments
 (0)