From ef310574da8ce2c987e5fd3fae1cab622ef54b18 Mon Sep 17 00:00:00 2001 From: Lex Christopherson Date: Thu, 26 Mar 2026 16:03:07 -0600 Subject: [PATCH] fix: Remove premature pendingTools.delete in webSearchResult handler (#2743) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The webSearchResult branch deleted entries from pendingTools after rendering, which removed the duplicate-prevention guard. Subsequent streaming tokens re-iterated content blocks, re-created the serverToolUse component, and re-rendered the search result — producing 18+ duplicate blocks. The message_end handler already calls pendingTools.clear(), so the explicit deletes were unnecessary and harmful. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../src/modes/interactive/controllers/chat-controller.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts b/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts index 7f9fe7044..ebe9231ed 100644 --- a/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +++ b/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts @@ -150,7 +150,6 @@ export async function handleAgentEvent(host: InteractiveModeStateHost & { content: [{ type: "text", text: "Web search disabled (offline mode)" }], isError: false, }); - host.pendingTools.delete(content.toolUseId); } else { const searchContent = content.content; const isError = searchContent && typeof searchContent === "object" && "type" in (searchContent as any) && (searchContent as any).type === "web_search_tool_result_error"; @@ -158,7 +157,6 @@ export async function handleAgentEvent(host: InteractiveModeStateHost & { content: [{ type: "text", text: host.formatWebSearchResult(searchContent) }], isError: !!isError, }); - host.pendingTools.delete(content.toolUseId); } } }