Skip to content

Commit cea64f3

Browse files
committed
fix: honour tool error suppression for mutating tools
1 parent b10b946 commit cea64f3

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/agents/pi-embedded-runner/run/payloads.errors.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,13 +353,14 @@ describe("buildEmbeddedRunPayloads", () => {
353353

354354
it.each([
355355
{
356-
name: "still shows mutating tool errors when messages.suppressToolErrors is enabled",
356+
name: "suppresses mutating tool errors when messages.suppressToolErrors is enabled",
357357
payload: {
358358
lastToolError: { toolName: "write", error: "connection timeout" },
359359
config: { messages: { suppressToolErrors: true } },
360360
},
361361
title: "Write",
362362
absentDetail: "connection timeout",
363+
suppressed: true,
363364
},
364365
{
365366
name: "shows recoverable tool errors for mutating tools",
@@ -377,8 +378,12 @@ describe("buildEmbeddedRunPayloads", () => {
377378
title: "Browser",
378379
absentDetail: "connection timeout",
379380
},
380-
])("$name", ({ payload, title, absentDetail }) => {
381+
])("$name", ({ payload, title, absentDetail, suppressed }) => {
381382
const payloads = buildPayloads(payload);
383+
if (suppressed) {
384+
expect(payloads).toEqual([]);
385+
return;
386+
}
382387
expectSingleToolErrorPayload(payloads, { title, absentDetail });
383388
});
384389

src/agents/pi-embedded-runner/run/payloads.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ function resolveToolErrorWarningPolicy(params: {
150150
if (normalizedToolName === "sessions_send") {
151151
return { showWarning: false, includeDetails };
152152
}
153+
if (params.suppressToolErrors) {
154+
return { showWarning: false, includeDetails };
155+
}
153156
const isMutatingToolError =
154157
params.lastToolError.mutatingAction ?? isLikelyMutatingToolName(params.lastToolError.toolName);
155158
if (isMutatingToolError) {
@@ -161,9 +164,6 @@ function resolveToolErrorWarningPolicy(params: {
161164
if (isExecLikeToolName(params.lastToolError.toolName) && !includeDetails) {
162165
return { showWarning: false, includeDetails };
163166
}
164-
if (params.suppressToolErrors) {
165-
return { showWarning: false, includeDetails };
166-
}
167167
return {
168168
showWarning: !params.hasUserFacingReply && !isRecoverableToolError(params.lastToolError.error),
169169
includeDetails,

0 commit comments

Comments
 (0)