#3864: fix(agents): suppress exec/bash exit code errors from user display
agents
Cluster:
Tool Execution and Error Handling
## Summary
- Exec/bash exit code errors are now suppressed from user display
- These errors are treated as internal/recoverable errors that the model should handle
## Problem
When using Telegram, exec tool errors like this were being sent to users:
```
⚠️ 🛠️ Exec: clawdbot status | grep -A5 "Runtime\|verbose\|elevated\|Think" failed: Command exited with code 1
```
Non-zero exit codes from commands like `grep` (no matches = exit 1) are normal workflow results, not failures that users need to see.
## Solution
Added `exec`/`bash` exit code errors to the `isRecoverableError` check in `buildEmbeddedRunPayloads()`. Now these errors:
- Stay in the model's context for internal handling
- Are not surfaced to users
- Allow the model to retry or continue appropriately
## Test plan
- [x] Updated existing test expectations
- [x] Added new tests for exec and bash exit code suppression
- [x] All 14 payloads tests pass
- [x] Lint/type check pass
Fixes #3765
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates `buildEmbeddedRunPayloads()` to classify `exec`/`bash` “exited with code …” tool errors as recoverable, preventing those tool failures from being included in user-visible payloads. Tests were updated and expanded to cover suppression for `exec` and `bash` exit code error cases, aligning behavior with Telegram’s UX needs where non-zero exit codes (e.g., `grep` no matches) are normal.
The change fits into the existing payload-building logic that already suppresses certain internal/retryable tool errors (validation/missing params) so the model can handle retries without surfacing noisy tool failures to end users.
<h3>Confidence Score: 3/5</h3>
- Mostly safe to merge, but current suppression may hide genuinely actionable exec/bash failures.
- The code change is small and covered by tests, but it broadens suppression to any exec/bash error containing “exited with code”, which can include real failures (e.g., bash 127) and may lead to users receiving no message when there’s no assistant output.
- src/agents/pi-embedded-runner/run/payloads.ts (recoverable error classification logic)
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#18415: fix(agents): suppress benign exec exit code 1 from tool error surfa...
by aldoeliacim · 2026-02-16
81.0%
#19632: fix: suppressToolErrors now suppresses exec tool failure notifications
by Gitjay11 · 2026-02-18
78.5%
#17950: fix: filter error payloads from user-facing messages
by Suksham-sharma · 2026-02-16
77.6%
#18466: fix: suppress recoverable mutating tool errors when agent already r...
by stijnhoste · 2026-02-16
76.9%
#10261: fix(agents): prevent exec tool errors from leaking to channels (#9651)
by nu-gui · 2026-02-06
76.1%
#20382: fix: move suppressToolErrors check before mutating tool check
by klawdius-noodle · 2026-02-18
75.5%
#19375: telegram: align tool-error summaries
by NorthyIE · 2026-02-17
75.4%
#9085: fix: improve stability for terminated responses and telegram retries
by vladdick88 · 2026-02-04
75.4%
#2541: fix(agents): add error handling to orphaned message cleanup
by Episkey-G · 2026-01-27
75.3%
#18992: fix: suppress spurious tool error warnings for read-only exec commands
by Phineas1500 · 2026-02-17
75.2%