fix(agent): respect suppressToolErrors for all tools including mutating ones

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
This commit is contained in:
ziy 2026-03-20 22:36:16 +08:00
parent dc86b6d72a
commit 9689d204f7

View File

@ -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,