#19375: telegram: align tool-error summaries
channel: telegram
size: XS
Cluster:
Tool Execution and Error Handling
## Summary\n- suppress redundant tool-error warning payloads before Telegram delivery so the bridge stays in sync with the TUI\n- add a bot-message-dispatch test that proves tool errors are no longer sent as standalone replies\n\n## Testing\n- pnpm test -- src/telegram/bot-message-dispatch.test.ts\n\nFixes #19336
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR suppresses redundant tool-error warning payloads in the Telegram bot dispatch path so that the bridge behaviour matches the TUI — tool errors are shown inline (during the run) and not re-sent as a standalone follow-up reply after the run completes.
The implementation adds a `isToolErrorWarning` helper using `/^⚠️.*\bfailed\b/i` and guards the suppression with `info.kind === "final" && payload.isError === true`. Because the guard requires `payload.isError === true` (strict equality), system-generated fallback messages such as `"⚠️ Agent failed before reply: …"` — which are returned as `kind: "final"` payloads **without** `isError` set — are correctly passed through and not suppressed.
Key observations:
- The `payload.isError === true` guard is correct and prevents over-suppression of non-tool-error system messages.
- The broad regex is safely constrained by the `isError` check.
- The new test (`"skips redundant tool error summaries for Telegram"`) partially overlaps with the modified existing test (`"does not edit preview message when final payload is an error"`), but the two cover slightly different scenarios (with and without a draft stream in flight), so both are useful.
- No existing tests were broken; the change to the existing test (replacing `expect(deliverReplies).toHaveBeenCalledWith(…)` with `expect(deliverReplies).not.toHaveBeenCalled()`) correctly reflects the new suppression behaviour.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge; the suppression guard is correctly scoped and system error messages are unaffected.
- The `payload.isError === true` strict-equality guard prevents any over-suppression of non-tool-error system messages. The regex is intentionally broad but is safely gated. Tests are updated and pass. The only mild concern is that the new test is partially redundant with the modified existing test, but that is a style issue rather than a correctness problem. Previously-raised thread concerns about `payload.isError !== false` and the suppression condition being a no-op have been addressed in this version of the code.
- No files require special attention.
<sub>Last reviewed commit: 109330f</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19235: fix(telegram): tool error warnings no longer overwrite streamed rep...
by gatewaybuddy · 2026-02-17
84.5%
#20842: fix(telegram): preserve preview when only error payloads are delivered
by marcodelpin · 2026-02-19
83.1%
#18678: fix(telegram): preserve draft message when all final payloads are e...
by julianubico · 2026-02-16
81.4%
#19632: fix: suppressToolErrors now suppresses exec tool failure notifications
by Gitjay11 · 2026-02-18
81.3%
#18187: fix: tool summaries silently dropped when reasoningLevel is stream
by ayanesakura · 2026-02-16
81.1%
#19399: telegram: fix MEDIA false positives and partial final drop
by HOYALIM · 2026-02-17
81.1%
#20382: fix: move suppressToolErrors check before mutating tool check
by klawdius-noodle · 2026-02-18
80.1%
#17953: fix(telegram): prevent silent message loss and duplicate messages i...
by zuyan9 · 2026-02-16
80.0%
#11340: Telegram: skip empty message text instead of throwing (#11238)
by lailoo · 2026-02-07
79.9%
#7141: fix(telegram): unify network error detection to prevent poll crashes
by hclsys · 2026-02-02
79.7%