From f2fd3642ffb8ebc13ec6a5f37db955dc0a715f1d Mon Sep 17 00:00:00 2001 From: Nate Date: Thu, 28 Aug 2025 19:48:50 -0700 Subject: [PATCH] fix: don't add system message on tool call errors in serve --- extensions/cli/src/commands/serve.helpers.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/extensions/cli/src/commands/serve.helpers.ts b/extensions/cli/src/commands/serve.helpers.ts index bb10f8bdc..35d67116d 100644 --- a/extensions/cli/src/commands/serve.helpers.ts +++ b/extensions/cli/src/commands/serve.helpers.ts @@ -58,7 +58,9 @@ export async function streamChatResponseWithInterruption( } }, onToolError: (error: string, toolName?: string) => { - // Update the tool call state to errored status + // Only update the tool call state to errored status when tool name is provided + // The error message is already added as a separate tool result message + // by handleToolCalls/preprocessStreamedToolCalls/executeStreamedToolCalls if (toolName) { // Find and update the corresponding tool call state for (let i = state.session.history.length - 1; i >= 0; i--) { @@ -71,19 +73,11 @@ export async function streamChatResponseWithInterruption( ); if (toolState) { // Only update the status, not the output - // The error message is already added as a separate tool result message - // by handleToolCalls/preprocessStreamedToolCalls toolState.status = "errored"; break; } } } - } else { - // Generic error message when no tool name is provided - state.session.history.push({ - message: { role: "system", content: error }, - contextItems: [], - }); } }, onToolPermissionRequest: (