Skip to content

fix(telegram): stale callback buttons remain when a media callback can't be deleted - #159012

Merged
obviyus merged 4 commits into
openclaw:mainfrom
wakqasahmed:fix/issue-153490-telegram-delete-fallback
Oct 2, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
wakqasahmed:fix/issue-153490-telegram-delete-fallback

Conversation

@wakqasahmed

@wakqasahmed wakqasahmed commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #153490

What Problem This Solves

A Telegram callback on a media message can leave live buttons on the original photo beside a replacement text reply when both text editing and deletion fail.

User Impact

When deletion fails, OpenClaw now makes a best-effort attempt to clear the original inline keyboard before sending the replacement. Successful deletion and unrelated edit errors keep their existing behavior.

Implementation

Uses the existing callback keyboard-edit owner. The contributor commits are preserved. The merge with current main keeps its shared replacement parameters and migrates the added regression to the existing session-directory test fixture.

No overlap with Pash/Sarah changes.

Evidence

Candidate: 411a3c05f13df416f0e47e64fd84778517680986.

  • The production router regression fails with the main callback owner: answerCallbackQuery → editMessageText → deleteMessage → sendMessage, missing editMessageReplyMarkup. It passes with the candidate: the empty keyboard edit precedes replacement delivery.
  • Focused candidate checks: transport-payload.test.ts 10 passed; model-callback.loopback.integration.test.ts 2 passed, 15.44 seconds including the repository runner. Hosted CI timing is reported by CI, not estimated here.
  • Built runtime exercised in isolated Docker, with task-owned state and heartbeats disabled.
  • Real Telegram Test Server, mock model photo producer: OpenClaw's message tool sends photos with inline buttons. The fixture installs the native model-picker callback on those photos before the TDLib tester taps; generic presentation callbacks have a separate namespace and do not reach this bug. The proxy rejects exactly one deleteMessage with a Bot API 400 and forwards every other call unchanged.
  • Base: built with the exact callback owner from main d7fd9a7dea11b529738562d6ae472788e5085620. Photo 47652536320 retains its Select mini keyboard after a completed tap and rejected deletion; replacement 47653584896 arrives. No post-tap keyboard edit or deletion appears through the 125-second recording.
  • Candidate: native photo 47647293440 is observed with a Select mini button, then a completed tap, then edit-meta with hasReplyMarkup: false, followed by replacement text 47649390592. Telegram returned 400 for the text edit, the proxy rejected deletion, and Telegram accepted the markup edit and replacement.
  • Normal-delete control: photo 47648342016 is tapped, Telegram accepts deletion, TDLib observes its deletion, and replacement 47650439168 arrives. No fallback keyboard edit occurs after that tap.
  • A separate real-provider attempt reached gpt-5-mini through a forward-only OpenAI proxy. Its four-call ceiling was enforced; auxiliary utility/embedding calls consumed the remaining calls before photo delivery. The callback proof above deliberately uses a deterministic mock model, not real-model output.

TDLib timeline (real Test Server user)

Times are milliseconds from each recording's start; message IDs belong to the observing user, not the bot's separate message-ID space.

Run Time Message Observed event
Base 30,676 47652536320 Photo's native Select mini keyboard present
Base 70,905 47652536320 Tester tap completed
Base 73,159 47653584896 Replacement text arrived; original keyboard unchanged
Candidate 30,696 47647293440 Photo's native Select mini keyboard present
Candidate 71,057 47647293440 Tester tap completed
Candidate 73,368 47647293440 updateMessageEdited: hasReplyMarkup=false
Candidate 74,359 47649390592 Replacement text arrived
Control 95,876 47648342016 Tester tap completed
Control 97,163 47648342016 Original photo deleted
Control 98,218 47650439168 Replacement text arrived

The proxy recorded one rejected deleteMessage per fault run (upstreamForwarded=false, error 400). Candidate's subsequent editMessageReplyMarkup and sendMessage both received Telegram 200 responses. The control's deleteMessage received 200 and did not use fallback markup cleanup.

Thanks to @aniruddhaadak80 for reporting and @wakqasahmed for the fix and regression coverage.

Contributor disclosure: AI-assisted (Claude Code).

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XS labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 5:55 AM ET / 09:55 UTC (Revision 4).

ClawSweeper review

What this changes

The Telegram plugin attempts to clear buttons from an undeletable media callback message before sending replacement text, with transport and callback-router regressions.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix: current main and the latest release retain the faulty fallback. The updated real Telegram evidence resolves the previous proof blocker, and no blocking patch defect was found.

Priority: P2
Reviewed head: 411a3c05f13df416f0e47e64fd84778517680986

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with relevant regressions and candidate-specific real Telegram traces meets normal good PR quality.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured candidate-specific Test Server trace exercises the changed callback message-action owner through a native model-picker tap: after text editing and deletion fail, Telegram accepts keyboard removal and TDLib observes it before replacement arrival. Base and normal-delete controls discriminate the repaired behavior; the mock model only produces the photo. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured candidate-specific Test Server trace exercises the changed callback message-action owner through a native model-picker tap: after text editing and deletion fail, Telegram accepts keyboard removal and TDLib observes it before replacement arrival. Base and normal-delete controls discriminate the repaired behavior; the mock model only produces the photo. No stored-data contract changes.
Evidence reviewed 7 items Pinned introduced change: The independently inspected merge-base-to-head delta adds an awaited best-effort empty-keyboard edit inside the existing deletion-failure catch; successful deletion and other edit-error branches are unchanged.
Still necessary on current main: Current main still catches deletion failure without clearing the keyboard before replacement delivery. The existing keyboard-edit owner already preserves business-message parameters; the patch reuses it without adding a parallel API or configuration path.
Latest release retains the defect: The v2026.9.7 tree identifies blob 95caac84ec44d0c3b72c9c80f6dc47546f246fa9 for this owner. Reading that blob through GitHub confirms the same empty deletion-failure catch and replacement send.
Findings None None.
Security None None.

How this fits together

Telegram button taps enter the callback router, which applies the selected action and updates its originating message. When Telegram cannot edit a media message as text, the message-action owner handles deletion and replacement delivery.

flowchart TD
  A[Telegram button tap] --> B[Callback router]
  B --> C[Edit original message]
  C -->|Media text edit rejected| D[Delete original message]
  D -->|Deletion rejected| E[Clear original buttons]
  D -->|Deleted| F[Send replacement text]
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +2, Tests +234. Total +236 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 1 +2
Tests 2 234 0 +234
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 237 1 +236

Review metrics

None.

Technical review

Best possible solution:

Keep callback cleanup in the existing message-action owner, preserving replacement delivery when Telegram also rejects keyboard removal.

Do we have a high-confidence way to reproduce the issue?

Yes: current main explicitly skips keyboard cleanup when a media text edit and subsequent deletion fail; the supplied Test Server baseline independently reports that outcome. This reviewer did not execute the reproduction.

Is this the best way to solve the issue?

Yes: reusing the existing keyboard-edit operation is a narrow repair that preserves successful deletion and replacement behavior without introducing another owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against aa31aeefb745.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured candidate-specific Test Server trace exercises the changed callback message-action owner through a native model-picker tap: after text editing and deletion fail, Telegram accepts keyboard removal and TDLib observes it before replacement arrival. Base and normal-delete controls discriminate the repaired behavior; the mock model only produces the photo. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured candidate-specific Test Server trace exercises the changed callback message-action owner through a native model-picker tap: after text editing and deletion fail, Telegram accepts keyboard removal and TDLib observes it before replacement arrival. Base and normal-delete controls discriminate the repaired behavior; the mock model only produces the photo. No stored-data contract changes.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs a bounded Telegram callback failure that leaves confusing, still-clickable controls beside replacement text.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured candidate-specific Test Server trace exercises the changed callback message-action owner through a native model-picker tap: after text editing and deletion fail, Telegram accepts keyboard removal and TDLib observes it before replacement arrival. Base and normal-delete controls discriminate the repaired behavior; the mock model only produces the photo. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured candidate-specific Test Server trace exercises the changed callback message-action owner through a native model-picker tap: after text editing and deletion fail, Telegram accepts keyboard removal and TDLib observes it before replacement arrival. Base and normal-delete controls discriminate the repaired behavior; the mock model only produces the photo. No stored-data contract changes.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Removal of the old inline keyboard is user-visible Telegram behavior, and the supplied Test Server trace covers it.

Evidence

What I checked:

  • Pinned introduced change: The independently inspected merge-base-to-head delta adds an awaited best-effort empty-keyboard edit inside the existing deletion-failure catch; successful deletion and other edit-error branches are unchanged. (extensions/telegram/src/bot-handlers.callback-actions.ts:90, 411a3c05f13d)
  • Still necessary on current main: Current main still catches deletion failure without clearing the keyboard before replacement delivery. The existing keyboard-edit owner already preserves business-message parameters; the patch reuses it without adding a parallel API or configuration path. (extensions/telegram/src/bot-handlers.callback-actions.ts:89, aa31aeefb745)
  • Latest release retains the defect: The v2026.9.7 tree identifies blob 95caac84ec44d0c3b72c9c80f6dc47546f246fa9 for this owner. Reading that blob through GitHub confirms the same empty deletion-failure catch and replacement send. (extensions/telegram/src/bot-handlers.callback-actions.ts, c074824a27c9)
  • Real Telegram proof resolves prior request: The captured PR body identifies candidate 411a3c0 and reports an isolated built runtime with a real Test Server user. Following a native model-picker tap and injected deletion rejection, TDLib observes the original keyboard removed at 73,368 ms and replacement text arriving at 74,359 ms; Telegram accepts both requests. The base retains its keyboard, while a successful-deletion control skips fallback cleanup. This directly addresses the previous review's retained rank-up move. Evidence is copied runtime output; no linked media was supplied for independent visual inspection. (411a3c05f13d)
  • Regression coverage: The complete tests were read. The added router case uses a real grammY client and local HTTP fault server to assert cleanup-before-replacement ordering; the transport case checks empty-keyboard serialization. The body reports a failing baseline regression, 10 transport tests and 2 router tests passing, and 15.44 seconds for the router runner. Tests were not executed during this read-only review. (extensions/telegram/src/model-callback.loopback.integration.test.ts:251, 411a3c05f13d)
  • Related work and review continuity: [Bug]: Telegram callback delete-failure swallowed, stale live buttons plus new reply #153490 describes this exact media-edit/deletion failure and remains open with this PR as its implementation candidate. The previous review had no findings and requested real Test Server evidence, which the captured updated body now supplies.

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-26T16:26:09.227Z sha b7bdf63 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-26T16:32:39.011Z sha b7bdf63 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-01T10:15:24.260Z sha 3ce6be0 :: needs real behavior proof before merge. :: none

Adds a full-router loopback test (real grammY bot, real local HTTP
Bot API, real session store) exercising the model-picker callback on
a media message whose edit and delete both fail. It asserts the
clear-buttons request (editMessageReplyMarkup with an empty keyboard)
is sent before the replacement confirmation, proving the fix's
runtime behavior end to end rather than only at the transport-payload
level.

Ref: openclaw#153490
@wakqasahmed

Copy link
Copy Markdown
Contributor Author

I went through the full review and want to be upfront about what I could and couldn't address.

The two blocking items both come down to the same ask: live Telegram evidence (via the telegram-e2e-userbot skill against Telegram's Test Server with leased Convex credentials) showing the old media message's buttons actually disappear before the replacement text shows up, not just a synthetic transport-level check.

What I added: extensions/telegram/src/model-callback.loopback.integration.test.ts now has a second test that drives the real model-picker flow through createTelegramCallbackRouter with a real grammY Bot instance talking to a real local HTTP server standing in for the Bot API (same pattern as the existing loopback test in that file, just with the original message built as a media message with no text). It injects a real 400 "no text in the message to edit" on editMessageText and a real "message can't be deleted" on deleteMessage, then asserts the full request sequence is answerCallbackQuery -> editMessageText -> deleteMessage -> editMessageReplyMarkup (inline_keyboard: []) -> sendMessage, with the clear-buttons call strictly before the replacement send. That's a step up from the original transport-payload.test.ts addition: it goes through the live callback router, authorization, and session persistence rather than calling the actions object directly.

What I did not do, and can't do from here: run this against Telegram's actual Test Server. The telegram-e2e-userbot skill needs a leased Convex credential (OPENCLAW_QA_CONVEX_SITE_URL / OPENCLAW_QA_CONVEX_SECRET_CI, or an authenticated convex CLI with broker access), and none of that is available in my environment. I checked for an existing authenticated launcher first and came up empty rather than guessing. I don't want to claim a live run happened when it didn't, so I'm flagging this honestly instead of papering over it.

If someone with access to the QA broker can run the telegram-e2e-userbot skill against this branch (or point me at how to get a lease), I'll pull in the recording and update the PR body. Otherwise this is as far as I can take the proof from this side.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 2, 2026
@obviyus
obviyus merged commit 2ced53d into openclaw:main Oct 2, 2026
111 checks passed
@obviyus

obviyus commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Landed as 2ced53d. Thanks @wakqasahmed!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…n't be deleted (openclaw#159012)

Fixes openclaw#153490.

When a Telegram callback edit fails with "no text in the message" (a media message) and deleting the original also fails, the original inline keyboard is now cleared before the replacement is sent, so stale buttons no longer stay live.

Proof: real Telegram Test Server with TDLib observation and a real tap, with exactly one deleteMessage rejected per fault run. main kept the photo's keyboard while the replacement arrived; this change clears it first. The normal path (delete succeeds) is unchanged. The photo with buttons came from a mock model; a real gpt-5-mini request on this head confirmed the provider path. Regression test fails on main and passes here.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram callback delete-failure swallowed, stale live buttons plus new reply

2 participants