From 57ea735a6a247baef72f9f9820860e3785a1d8cb Mon Sep 17 00:00:00 2001 From: daniel-lxs Date: Wed, 10 Dec 2025 13:17:24 -0500 Subject: [PATCH] fix: prevent premature rawChunkTracker clearing for MCP tools The processFinishReason() method was clearing rawChunkTracker immediately after emitting tool_call_end events. However, Task.ts doesn't process these events in the main streaming loop - they're only processed via the fallback mechanism in finalizeRawChunks(). This caused MCP tools to never be converted from tool_use to mcp_tool_use type, resulting in 'unknown tool' errors. The fix removes the redundant clear() call from processFinishReason(). The tracker is still properly cleared by: 1. finalizeRawChunks() - after processing remaining tools (line 180) 2. clearRawChunkState() - when a new API request starts --- src/core/assistant-message/NativeToolCallParser.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/assistant-message/NativeToolCallParser.ts b/src/core/assistant-message/NativeToolCallParser.ts index 6bdefb107c3..eaef28a5382 100644 --- a/src/core/assistant-message/NativeToolCallParser.ts +++ b/src/core/assistant-message/NativeToolCallParser.ts @@ -156,7 +156,6 @@ export class NativeToolCallParser { id: tracked.id, }) } - this.rawChunkTracker.clear() } return events