← Back to PRs

#19375: telegram: align tool-error summaries

by NorthyIE open 2026-02-17 18:43 View on GitHub →
channel: telegram size: XS
## 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