#22087: Preserve assistant reply when exec fails under suppressToolErrors
agents
size: XS
Cluster:
Tool Execution and Error Handling
## Summary
- Preserve user-facing assistant replies when `messages.suppressToolErrors=true` and an `exec`/mutating tool call fails.
- Add a regression test covering the `assistantTexts + exec failure + suppressToolErrors` path.
## Expected vs Actual
- Expected: with `suppressToolErrors=true`, assistant reply text remains visible; tool warning should not override it.
- Actual (before): mutating tool warning path could still append error warnings even when a user-facing reply already existed.
## Impact
- Prevents noisy mutating-tool warnings from dominating final output in runs that already produced a user-visible answer.
- Keeps existing safety behavior for no-reply cases unchanged.
## Reproduction
1. Set `messages.suppressToolErrors: true`.
2. Trigger a run that produces assistant text and also hits an `exec` failure.
3. Observe that only assistant text is kept after this patch.
## Issues Found
| ID | Issue | Severity | Status |
| --- | --- | --- | --- |
| PR-22087-BUG-01 | `suppressToolErrors` did not suppress mutating/exec warning when assistant text already existed. | medium | fixed |
## Fix Approach
- In `shouldShowToolErrorWarning`, short-circuit to `false` when both conditions are true:
- `suppressToolErrors` is enabled
- a user-facing assistant reply already exists
- Leave mutating-tool warning behavior unchanged for no-reply runs.
## Testing
- `pnpm test src/agents/pi-embedded-runner/run/payloads.test.ts`
Fixes #19820
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added logic to preserve assistant replies when `suppressToolErrors` is enabled and a mutating tool (like `exec`) fails. The fix prevents noisy tool error warnings from overriding user-facing assistant text when the user has explicitly requested error suppression.
Key changes:
- Added short-circuit condition in `shouldShowToolErrorWarning` that returns false when both `suppressToolErrors` is enabled and a user-facing reply exists
- Preserves existing safety behavior for mutating tool failures when no assistant reply is present
- Added regression test covering the `assistantTexts + exec failure + suppressToolErrors` scenario
The implementation is clean and the logic placement is correct - it handles the specific case without breaking existing behavior for other scenarios.
<h3>Confidence Score: 5/5</h3>
- Safe to merge with no risk
- The logic is well-placed and preserves all existing safety behaviors while fixing the specific issue. The test coverage is appropriate and verifies the fix works as intended. The change is minimal, focused, and doesn't introduce any edge cases or breaking changes.
- No files require special attention
<sub>Last reviewed commit: 6db89f3</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#17552: fix(agents): suppress tool error warnings when assistant already re...
by AytuncYildizli · 2026-02-15
86.3%
#18466: fix: suppress recoverable mutating tool errors when agent already r...
by stijnhoste · 2026-02-16
86.3%
#19632: fix: suppressToolErrors now suppresses exec tool failure notifications
by Gitjay11 · 2026-02-18
85.7%
#20382: fix: move suppressToolErrors check before mutating tool check
by klawdius-noodle · 2026-02-18
85.0%
#18415: fix(agents): suppress benign exec exit code 1 from tool error surfa...
by aldoeliacim · 2026-02-16
81.6%
#4844: fix(agents): skip error/aborted assistant messages in transcript re...
by lailoo · 2026-01-30
81.2%
#18992: fix: suppress spurious tool error warnings for read-only exec commands
by Phineas1500 · 2026-02-17
80.7%
#9416: fix: drop errored/aborted assistant tool pairs in transcript repair
by xandorklein · 2026-02-05
80.1%
#19235: fix(telegram): tool error warnings no longer overwrite streamed rep...
by gatewaybuddy · 2026-02-17
79.4%
#16966: fix: strip tool_use blocks from aborted/errored assistant messages
by StressTestor · 2026-02-15
79.1%