From 3dd3303498e07ffbe8593bec62de7ccfb1335e18 Mon Sep 17 00:00:00 2001 From: gitfromwildan <201965665+gitfromwildan@users.noreply.github.com> Date: Fri, 31 Jul 2026 21:04:49 +0700 Subject: [PATCH] =?UTF-8?q?fix(xl-ai):=20Array.from=20on=20filtered=20iter?= =?UTF-8?q?ator=20=E2=80=94=20tool=20calls=20never=20marked=20complete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit s.values() returns a MapIterator/SetIterator, not an array. Calling .filter() directly on an iterator throws TypeError or silently fails depending on the runtime. Move .filter() after Array.from() to fix tool call completion detection. Fixes #2933 --- .../xl-ai/src/streamTool/vercelAiSdk/util/chatHandlers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/xl-ai/src/streamTool/vercelAiSdk/util/chatHandlers.ts b/packages/xl-ai/src/streamTool/vercelAiSdk/util/chatHandlers.ts index 30d0335a4d..4b3c05d000 100644 --- a/packages/xl-ai/src/streamTool/vercelAiSdk/util/chatHandlers.ts +++ b/packages/xl-ai/src/streamTool/vercelAiSdk/util/chatHandlers.ts @@ -144,8 +144,8 @@ export async function setupToolCallStreaming( let errorSeen = false; // process results const toolCalls = Array.from( - toolCallStreams.values().filter((data) => data.complete), - ); + toolCallStreams.values(), + ).filter((data) => data.complete); toolCalls.forEach((toolCall, index) => { const isErrorTool = toolCall.toolCallId === error?.chunk.metadata.toolCallId;