mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 09:00:21 +00:00
feat: add messages.suppressToolErrors config option (#16620)
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 9ae4394b81
Co-authored-by: vai-oro <258511217+vai-oro@users.noreply.github.com>
Co-authored-by: sebslight <19554889+sebslight@users.noreply.github.com>
Reviewed-by: @sebslight
This commit is contained in:
@@ -278,6 +278,42 @@ describe("buildEmbeddedRunPayloads", () => {
|
||||
expect(payloads).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("suppresses non-mutating non-recoverable tool errors when messages.suppressToolErrors is enabled", () => {
|
||||
const payloads = buildEmbeddedRunPayloads({
|
||||
assistantTexts: [],
|
||||
toolMetas: [],
|
||||
lastAssistant: undefined,
|
||||
lastToolError: { toolName: "browser", error: "connection timeout" },
|
||||
config: { messages: { suppressToolErrors: true } },
|
||||
sessionKey: "session:telegram",
|
||||
inlineToolResultsAllowed: false,
|
||||
verboseLevel: "off",
|
||||
reasoningLevel: "off",
|
||||
toolResultFormat: "plain",
|
||||
});
|
||||
|
||||
expect(payloads).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("still shows mutating tool errors when messages.suppressToolErrors is enabled", () => {
|
||||
const payloads = buildEmbeddedRunPayloads({
|
||||
assistantTexts: [],
|
||||
toolMetas: [],
|
||||
lastAssistant: undefined,
|
||||
lastToolError: { toolName: "write", error: "connection timeout" },
|
||||
config: { messages: { suppressToolErrors: true } },
|
||||
sessionKey: "session:telegram",
|
||||
inlineToolResultsAllowed: false,
|
||||
verboseLevel: "off",
|
||||
reasoningLevel: "off",
|
||||
toolResultFormat: "plain",
|
||||
});
|
||||
|
||||
expect(payloads).toHaveLength(1);
|
||||
expect(payloads[0]?.isError).toBe(true);
|
||||
expect(payloads[0]?.text).toContain("connection timeout");
|
||||
});
|
||||
|
||||
it("shows recoverable tool errors for mutating tools", () => {
|
||||
const payloads = buildEmbeddedRunPayloads({
|
||||
assistantTexts: [],
|
||||
|
||||
@@ -233,7 +233,9 @@ export function buildEmbeddedRunPayloads(params: {
|
||||
const isMutatingToolError =
|
||||
params.lastToolError.mutatingAction ??
|
||||
isLikelyMutatingToolName(params.lastToolError.toolName);
|
||||
const shouldShowToolError = isMutatingToolError || (!hasUserFacingReply && !isRecoverableError);
|
||||
const shouldShowToolError =
|
||||
isMutatingToolError ||
|
||||
(!hasUserFacingReply && !isRecoverableError && !params.config?.messages?.suppressToolErrors);
|
||||
|
||||
// Always surface mutating tool failures so we do not silently confirm actions that did not happen.
|
||||
// Otherwise, keep the previous behavior and only surface non-recoverable failures when no reply exists.
|
||||
|
||||
Reference in New Issue
Block a user