From 9689d204f75296fbd33eaf9f076c2c5055b7be12 Mon Sep 17 00:00:00 2001 From: ziy Date: Fri, 20 Mar 2026 22:36:16 +0800 Subject: [PATCH] fix(agent): respect suppressToolErrors for all tools including mutating ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit suppressToolErrors was checked after the mutating-tool guard, making it ineffective for edit/write/exec/etc. Move the check to the top so that when config.messages.suppressToolErrors is true, NO tool-error warnings are shown to the user — the agent handles failures internally. Fixes #51065 --- src/agents/pi-embedded-runner/run/payloads.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/agents/pi-embedded-runner/run/payloads.ts b/src/agents/pi-embedded-runner/run/payloads.ts index a79fc592bf9..4f4c7ad2d54 100644 --- a/src/agents/pi-embedded-runner/run/payloads.ts +++ b/src/agents/pi-embedded-runner/run/payloads.ts @@ -61,6 +61,12 @@ function resolveToolErrorWarningPolicy(params: { verboseLevel?: VerboseLevel; }): ToolErrorWarningPolicy { const includeDetails = isVerboseToolDetailEnabled(params.verboseLevel); + // Check suppressToolErrors first so it takes precedence over all other rules. + // When true, no tool-error warnings are shown to the user — the agent handles + // failures internally and decides what to communicate. + if (params.suppressToolErrors) { + return { showWarning: false, includeDetails }; + } if (params.suppressToolErrorWarnings) { return { showWarning: false, includeDetails }; } @@ -79,9 +85,6 @@ function resolveToolErrorWarningPolicy(params: { if (isMutatingToolError) { return { showWarning: true, includeDetails }; } - if (params.suppressToolErrors) { - return { showWarning: false, includeDetails }; - } return { showWarning: !params.hasUserFacingReply && !isRecoverableToolError(params.lastToolError.error), includeDetails,