fix(sdk): mutate function receiving incorrect previous value (#1669)

This commit is contained in:
David Duong
2025-09-18 15:54:31 +02:00
committed by GitHub
parent e61f27d484
commit f21fd04930
2 changed files with 9 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@langchain/langgraph-sdk": patch
---
Fix mutate function in `onCustomEvent` and in `onUpdateEvent` receiving incorrect previous value
+4 -1
View File
@@ -163,7 +163,10 @@ export class StreamManager<
return (
update: Partial<StateType> | ((prev: StateType) => Partial<StateType>)
) => {
const prev = { ...historyValues, ...this.state.values };
const prev = {
...historyValues,
...(this.state.values ?? [null, "stream"])[0],
};
const next = typeof update === "function" ? update(prev) : update;
this.setStreamValues({ ...prev, ...next }, kind);
};