Repository navigation
fix(telegram): prevent duplicate replies after attachment delivery failures - #128181
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 23, 2026, 7:02 AM ET / 11:02 UTC. ClawSweeper reviewWhat this changesThe PR records accepted Telegram media and follow-up message IDs across later attachment failures so the channel can report partial delivery instead of treating the whole reply as absent. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked by patch quality or review findings - 6 items remain The patch records partial Telegram delivery, but ordinary final-reply dispatch still treats that rejection as a failed answer and sends the duplicate fallback; it needs one consumer-side repair before merge. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherTelegram’s reply sender delivers media and text through the Bot API, then returns a partial-delivery outcome when a later step fails. The normal dispatch layer uses that outcome to decide whether an error fallback should be sent to the chat. flowchart LR
A[Agent final reply] --> B[Normal Telegram dispatch]
B --> C[Media and text delivery]
C --> D[Accepted message IDs]
C --> E[Later attachment failure]
D --> F[Partial-delivery outcome]
E --> F
F --> G[Fallback decision]
G --> H[Telegram chat]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource -4, Tests +196. Total +192 across 2 files. View PR surface stats
Review metrics
Proof path suggestionA new before/after Telegram Desktop run can directly establish whether normal dispatch emits the duplicate fallback after the injected later attachment failure. Mantis is proof-only, so it must not be asked to change code or mutate GitHub state. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Consume a partial final-delivery error at the ordinary Telegram dispatch boundary, mark the final as visibly delivered before fallback selection, and prove the no-duplicate outcome through that complete path. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: make normal final delivery reject with CHANNEL_PARTIAL_DELIVERY after one accepted attachment; the current dispatcher records dispatchError and sends its error fallback because finalAnswerDelivered remains false. Is this the best way to solve the issue? No: preserving accepted IDs is the correct producer-side repair, but the ordinary fallback consumer must also recognize the partial outcome for the user-visible duplicate to disappear. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9046ecea7303. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Mantis Telegram Desktop ProofSummary: Mantis captured native Telegram Desktop before/after GIF evidence with Convex-leased Telegram credentials, but this comparison is blocked because baseline and candidate produced identical visible and Bot API facts.
Motion-trimmed clips: |
|
Merged via squash.
|




What Problem This Solves
Fixes an issue where Telegram users receiving multiple attachments could see an incorrect duplicate fallback reply after one photo, document, voice note, or voice fallback had already arrived and a later attachment failed to load or send.
Why This Change Was Made
Telegram's private delivery owner now records each accepted media message and each media-owned fallback or caption-follow-up text chunk immediately at its authoritative acceptance boundary, before fallible topic validation or bookkeeping. One outer owner boundary merges the complete accepted-message history into the existing partial-delivery contract; initial failures with no accepted message still propagate unchanged.
User Impact
Already delivered Telegram messages remain visible to native commands and channel lifecycle handling even when a later album item fails. Operators no longer receive a misleading duplicate empty-response fallback, and accepted media, voice-fallback, and caption-follow-up message IDs remain available for recovery and diagnostics.
Evidence
e3308ba36908796dff91cf8099e15c939c3056a1.OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-autoqa-telegram-partial-delivery-vitest-cache node scripts/run-vitest.mjs extensions/telegram/src/bot/delivery.test.ts extensions/telegram/src/bot-native-command-dispatch.delivery.test.ts extensions/telegram/src/bot-message-dispatch.delivery-basics.test.ts extensions/telegram/src/chunk-delivery.test.ts extensions/telegram/src/send.test.ts --configLoader runner— 5 files, 406 tests passed.git diff --checkall pass.promptStarted/elicitationModesdiagnostics; there are no errors in either changed Telegram file.