← Back to PRs

#18415: fix(agents): suppress benign exec exit code 1 from tool error surfacing

by aldoeliacim open 2026-02-16 18:03 View on GitHub →
agents stale size: XS trusted-contributor
## Problem Since v2026.2.14, tool calls that exit with code 1 (e.g. `grep` finding no matches, `diff` finding differences) are surfaced to users as ⚠️ failure warnings. This is noisy and confusing because exit code 1 is normal behavior for many CLI tools. The root cause: `exec` is classified as a mutating tool, and `shouldShowToolErrorWarning` always surfaces mutating tool failures. ## Fix Add `isBenignExecExit()` that checks if the tool is `exec`/`bash` and the error indicates exit code 1. This check runs before the mutation check, so benign exits are never surfaced. Exit codes >= 2 continue to be surfaced normally, as they indicate real errors. ## Changes - `src/agents/pi-embedded-runner/run/payloads.ts`: Add `isBenignExecExit()` helper and early-return in `shouldShowToolErrorWarning` - `src/agents/pi-embedded-runner/run/payloads.e2e.test.ts`: Update existing test + add test for exit code >= 2 ## Testing - Updated existing test that expected exit code 1 to surface (now suppressed) - Added test confirming exit code 2 still surfaces as error - All 21 tests in payloads.e2e.test pass Closes #18283 <!-- greptile_comment --> <h3>Greptile Summary</h3> Suppresses noisy exit-code-1 warnings from exec/bash tools (e.g. `grep` returning no matches, `diff` finding differences) that were incorrectly surfaced as failure warnings since v2026.2.14. Adds a targeted `isBenignExecExit()` check before the mutation-based warning logic so exit code 1 is treated as benign while exit codes >= 2 continue to surface normally. - Adds `EXEC_TOOL_NAMES` set and `BENIGN_EXIT_CODE_RE` regex to identify benign exec exit code 1 errors - Inserts an early-return in `shouldShowToolErrorWarning` before the mutation check - Updates existing test to verify exit code 1 suppression; adds new test confirming exit code 2 still surfaces - Note: suppression only applies when the error message string literally ends with "exited with code 1" — if the command produced aggregated output, the error text will be the first line of that output (due to `normalizeToolErrorText`), and the warning will still surface. This is acceptable for the targeted fix scope. <h3>Confidence Score: 4/5</h3> - This PR is safe to merge — it's a narrowly scoped fix with correct regex behavior and good test coverage. - The change is small and well-targeted. The regex `/exited with code 1$/i` correctly avoids false positives for multi-digit exit codes (verified via testing). The early-return placement before the mutation check is intentional and correct. Tests cover both the suppression (exit code 1) and passthrough (exit code 2) paths. One minor gap: no test for the "bash" tool name variant, but the implementation is straightforward Set lookup. The fix correctly addresses the reported regression. - No files require special attention <sub>Last reviewed commit: 19c023c</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs