perf(langgraph): Improve performance of createCheckpoint (#1621)

Co-authored-by: David Duong <david@duong.cz>
This commit is contained in:
Nuno Campos
2025-09-09 11:45:36 +01:00
committed by GitHub
parent d9a8f658e7
commit d35db59d6e
2 changed files with 7 additions and 9 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@langchain/langgraph": patch
---
Improve graph execution performance by avoiding unnecessary cloning of checkpoints after every tick
+2 -9
View File
@@ -169,19 +169,12 @@ export function createCheckpoint<ValueType>(
}
}
const newVersionsSeen = {} as Record<string, Record<string, number | string>>;
for (const k in checkpoint.versions_seen) {
if (!Object.prototype.hasOwnProperty.call(checkpoint.versions_seen, k))
continue;
newVersionsSeen[k] = { ...checkpoint.versions_seen[k] };
}
return {
v: 4,
id: options?.id ?? uuid6(step),
ts: new Date().toISOString(),
channel_values: values,
channel_versions: { ...checkpoint.channel_versions },
versions_seen: newVersionsSeen,
channel_versions: checkpoint.channel_versions,
versions_seen: checkpoint.versions_seen,
};
}