fix: handle subgraph custom events in stream processing (#1459)

Co-authored-by: Tat Dat Duong <david@duong.cz>
This commit is contained in:
Maurits Brinkman
2025-07-29 17:39:20 +01:00
committed by GitHub
parent 1777878476
commit f43e48ce06
2 changed files with 13 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@langchain/langgraph-sdk": patch
---
fix(sdk): handle subgraph custom events in stream processing of useStream
+8 -2
View File
@@ -1065,8 +1065,13 @@ export function useStream<
}
if (event === "updates") options.onUpdateEvent?.(data);
if (event === "custom")
options.onCustomEvent?.(data, {
if (
event === "custom" ||
// if `streamSubgraphs: true`, then we also want
// to also receive custom events from subgraphs
event.startsWith("custom|")
)
options.onCustomEvent?.(data as CustomType, {
mutate: getMutateFn("stream", historyValues),
});
if (event === "metadata") options.onMetadataEvent?.(data);
@@ -1203,6 +1208,7 @@ export function useStream<
onThreadId(thread.thread_id);
usableThreadId = thread.thread_id;
}
if (!usableThreadId) throw new Error("Failed to obtain valid thread ID.");
const streamMode = unique([
...(submitOptions?.streamMode ?? []),