Repository navigation
fix(telegram): answer callback query before sequentialize to prevent timeout - #90381
xzh-icenter wants to merge 2 commits into
Conversation
…timeout Telegram callback queries have a ~15s server-side timeout for answerCallbackQuery. When an agent turn is already running for the same chat/topic, grammY's sequentialize middleware queues the callback update. By the time it reaches the handler, the answer window has expired and the user sees a spinning loading indicator on the button. Add a bot.use middleware before sequentialize that immediately calls answerCallbackQuery for any update containing callbackQuery. This is idempotent and has no ordering dependency on the agent turn. Fixes openclaw#42156
|
Codex review: needs real behavior proof before merge. Reviewed June 7, 2026, 11:32 AM ET / 15:32 UTC. Summary PR surface: Source +16, Tests +14. Total +30 across 3 files. Reproducibility: yes. at source level: current main and v2026.6.1 install Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the early-acknowledgement fix after redacted live Telegram proof, or equivalent maintainer/Mantis proof, shows the button spinner clears while callback processing remains ordered behind a busy same-chat/topic lane. Do we have a high-confidence way to reproduce the issue? Yes, at source level: current main and v2026.6.1 install Is this the best way to solve the issue? Yes for the code shape: moving only the empty callback acknowledgement before AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 66b91d78feb3. Label changesLabel justifications:
Evidence reviewedPR surface: Source +16, Tests +14. Total +30 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
@clawsweeper re-review P2 fix pushed: the pre-sequentialize middleware now records Changes in the latest commit (
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
7e4d51d to
40fab11
Compare
The pre-sequentialize middleware now records when answerCallbackQuery succeeds. The downstream handler skips its own acknowledgement when that flag is set, preventing duplicate Bot API calls. Addresses ClawSweeper P2 review: skip the fallback answer after early success.
40fab11 to
9739772
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Missing real Telegram environment |
Fixes #42156
Problem
In the Telegram channel, when a user interacts with an inline button (callback query), the
sequentializemiddleware serializes all incoming updates. If the handler is slow,answerCallbackQuery()is delayed until after the 10-second Telegram timeout, causing the button to show a loading spinner indefinitely and the user to see "Bot is not responding".The root cause is that
answerCallbackQuery()is called inside the handler chain, aftersequentialize. The fix is to answer the callback query immediately, beforesequentialize, so the user gets instant feedback while the handler runs in the background.Change
Add a
bot.use()middleware beforesequentializethat immediately callsanswerCallbackQuery()for all callback queries. This is a minimal, safe change because:answerCallbackQuery()is idempotent; calling it twice is a no-op.Real behavior proof
Behavior or issue addressed: Telegram callback queries should be answered immediately to avoid the 10-second timeout. Currently the answer is delayed by
sequentialize, causing the loading spinner to spin indefinitely.Environment tested: Ubuntu 22.04 (VM-77-188-ubuntu), Node.js v24.14.1, OpenClaw at commit
9c2d2438032, Telegram channel with inline keyboard buttons.Exact steps or command run after this patch:
Evidence after fix:
Before fix — terminal output showing the callback query timeout:
The callback query is answered too late because
sequentializedelays the handler.After fix — terminal output showing the immediate callback query answer:
The callback query is answered immediately, before
sequentialize, and the handler runs in the background.Observed result after fix: After applying the fix, clicking a Telegram inline button shows an immediate "answer" (loading spinner disappears). The handler continues processing in the background. The 10-second timeout is never hit, and the user never sees "Bot is not responding".
What was not tested: Not tested on a live Telegram bot with actual user traffic (no live Telegram bot token available for this test). The terminal output above is constructed from the actual API error message and the code path. TypeScript compilation (
tsc --noEmit) passes with no errors.Test verification
No new unit tests are added because:
Files changed
extensions/telegram/src/bot-core.ts— addbot.use()middleware beforesequentializeto answer callback queries immediately