Skip to content

fix(telegram): finalize streamed questions in place - #126248

Merged
steipete merged 4 commits into
mainfrom
steipete/fix-telegram-streamed-questions
Aug 20, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/fix-telegram-streamed-questions

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where streamed Telegram ask_user prompts could bypass question registration, report button attachment failure as success, or generate a duplicate fallback after a visible partial delivery.

Why This Change Was Made

Register the concrete preview message, share control-first bounded finalization with durable delivery, and treat visible-but-unusable prompts as terminal delivery failures while preserving answer races.

User Impact

Telegram questions finalize on the same message, clear buttons when answered, and cancel cleanly without duplicate output when controls fail.

Evidence

  • 112 Telegram tests and 45 core delivery/tool tests passed.
  • Core/plugin production and test typechecks, node scripts/check-changed.mjs, pnpm build, and autoreview passed.
  • Production LOC +165/-22 (net +143); tests/support +182/-67.
  • AI-assisted; maintainer reviewed the implementation and proof.

@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 19, 2026 07:43
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Aug 19, 2026
@clawsweeper clawsweeper Bot added mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 10:01 PM ET / August 20, 2026, 02:01 UTC.

ClawSweeper review

What this changes

The PR finalizes streamed Telegram ask-user prompts on their existing message, registers that concrete message with the question gateway, and turns failed control attachment into a terminal partial-delivery outcome to prevent duplicate fallback messages.

Regression provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open. The prior P1 is addressed at the exact head, but the stated evidence remains mock-only while the scoped Telegram policy requires real Telegram proof for streaming/callback behavior; exact-head CI is also still incomplete.

Priority: P1
Reviewed head: 36d0675c524f1370b60cb6c68da6bad61c59abec

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 6 items Prior P1 is addressed: The previously missing rotation path now calls the canonical finalized-preview handler, which marks the visible preview delivered and throws a receipt-preserving partial-delivery error before rotation can produce fallback output.
Core outcome reaches ask_user: The queued-delivery owner now carries every non-delivered outcome as a typed error, and ask_user treats failed-deliver as a terminal, no-retry cancellation while preserving the answer race.
Question-gateway contract inspected: The plugin SDK directly exposes registerChannelDelivery, whose owner records the delivery and finalizes terminal questions once per delivery ID; this is the dependency contract used by the new Telegram helper.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --helprunner@runnervmzvulz:/tmp/clawsweeper-live-proof-126248-nSZFb0/target$ pnpm openclaw --help
pnpm openclaw --help
$ node scripts/run-node.mjs --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 106.91 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 14.1s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 4362ms (slowest: built plugin control-plane loads 3597ms)

OpenClaw 2026.8.1 (36d0675) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console 
… output truncated …

Assertions:

  • PASS expect_output: Usage: openclaw

How this fits together

Telegram’s dispatcher streams a visible preview, attaches interactive controls, and registers ask-user messages with the shared question gateway. When a question resolves, the gateway calls the channel finalizer to remove controls and annotate that same Telegram message.

flowchart LR
A[Agent asks a question] --> B[Reply dispatcher]
B --> C[Telegram preview message]
C --> D[Attach controls and register question]
D --> E{Controls attached?}
E -->|Yes| F[Question gateway finalizes in place]
E -->|No| G[Terminal partial-delivery outcome]
G --> H[No fallback duplicate]
Loading

Before merge

  • Resolve merge risk (P1) - No after-fix real Telegram evidence demonstrates the visible streamed-question flow, control clearing, and no-duplicate outcome under a control-edit failure.
  • Resolve merge risk (P1) - Current-main comparison could not be completed because this review checkout lacks the main objects and cannot reach its promisor remote.
  • Resolve merge risk (P1) - The bug fix has author-reported net production growth, though the new helper does consolidate the outbound and dispatcher finalization paths; no smaller absorbing refactor is evident from the available source.
  • Complete next step (P2) - The protected maintainer item needs real Telegram proof and complete exact-head CI, not an automated source repair.
Agent review details

Security

None.

PR surface

Source +153, Tests +195. Total +348 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 12 197 44 +153
Tests 7 264 69 +195
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 461 113 +348

Review metrics

Metric Value Why it matters
Production versus test delta production net +141; tests/support net +198 (author-reported across the PR body and latest follow-up) The production growth establishes shared finalization and typed delivery outcomes, so real channel proof is the material remaining confidence reducer.

Stored data model

Persistent data-model change detected: serialized state: src/agents/tools/ask-user-tool.ts. Confirm migration or upgrade compatibility proof before merge.

Mantis proof suggestion

A Telegram Desktop proof would directly show the changed in-place prompt, controls, and terminal state while avoiding disclosure of credentials or private chat content. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: reproduce a streamed ask_user prompt, answer it, and capture the same message with controls cleared and its terminal status.

Merge-risk options

Maintainer options:

  1. Prove the channel behavior before merge (recommended)
    Run a redacted real Telegram streamed ask-user flow, including a deterministic control-edit failure, and show the existing preview is not followed by a fallback message.

Technical review

Best possible solution:

Capture a redacted real Telegram run that shows one streamed ask-user message becoming terminal in place, including the controlled edit-failure path with no fallback message, then land only after the exact-head checks are green.

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

No high-confidence live reproduction is supplied; the focused tests source-reproduce the injected control-edit failure, but do not exercise a real Telegram transport.

Is this the best way to solve the issue?

Unclear. The exact head centralizes both Telegram finalization callers and fixes the prior propagation gap, but a current-main comparison and real Telegram fault proof remain unavailable.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 19316660e418.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The patch changes whether active Telegram ask-user prompts can be finalized, cancelled, or duplicated for users.
  • merge-risk: 🚨 message-delivery: A failed control edit now determines whether a visible Telegram preview becomes terminal and whether fallback delivery is suppressed.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The PR changes visible Telegram question prompts, inline controls, terminal annotation, and duplicate-suppression behavior that a short Telegram Desktop recording can demonstrate.

Evidence

What I checked:

Likely related people:

  • steipete: The reachable exact-head blame for the finalized-preview and Telegram question-registration boundary attributes it to this author; earlier area history is unavailable in the shallow checkout. (role: current implementation author and likely follow-up owner; confidence: medium; commits: fa1fa9af014f, 7e5a59b416eb, 36d0675c524f; files: extensions/telegram/src/bot-message-dispatch-delivery.ts, extensions/telegram/src/question-finalization.ts, src/agents/tools/ask-user-tool.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Tighten the PR description with what changed, how it was validated, and any remaining risk.

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 (5 earlier review cycles)
  • reviewed 2026-08-19T07:50:19.253Z sha d88d887 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-19T09:11:02.942Z sha 86ff4b6 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-19T22:45:21.674Z sha 2c5a610a9727436fff50c302c8ae245229b00cfe :: needs maintainer review before merge. :: none
  • reviewed 2026-08-19T23:16:29.814Z sha c042765f4c0212a9465a9370eb13bcbd5232a1ca :: needs maintainer review before merge. :: none
  • reviewed 2026-08-20T01:09:40.479Z sha 03bb33c :: needs changes before merge. :: [P1] Propagate partial finalization through rotation

@steipete
steipete force-pushed the steipete/fix-terminal-tool-propagation branch from bd06ce9 to 8fb7526 Compare August 19, 2026 09:05
@steipete
steipete force-pushed the steipete/fix-telegram-streamed-questions branch from d88d887 to 86ff4b6 Compare August 19, 2026 09:05
@steipete
steipete force-pushed the steipete/fix-terminal-tool-propagation branch from 8fb7526 to 032d6ce Compare August 19, 2026 22:39
@steipete
steipete force-pushed the steipete/fix-telegram-streamed-questions branch from 86ff4b6 to 2c5a610 Compare August 19, 2026 22:39
Base automatically changed from steipete/fix-terminal-tool-propagation to main August 20, 2026 00:55
@steipete
steipete force-pushed the steipete/fix-telegram-streamed-questions branch from c042765 to 03bb33c Compare August 20, 2026 01:03
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Aug 20, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the exact-head P1 in 7e5a59b.

Pre-rotation materialization now uses the same canonical finalized-preview handler as ordinary reply delivery: it emits one terminal hook, marks the visible delivery final, and throws a merged partial-delivery error carrying the preview receipt, content, and platform message IDs. Because rotation awaits this handler, a failed control edit cannot rotate the lane or trigger a duplicate fallback. Successful rotation and final/media preview behavior keep the existing path.

Regression proof covers a queued ask_user answer block with buttons whose first edit succeeds and whose materialization edit fails before the next block. It asserts the partial error reaches the dispatcher, outer status becomes error, hook success is false, the concrete receipt is preserved, no question is registered, no fallback/new message is sent, and the lane does not rotate.

Validation:

  • 18 Telegram dispatcher/lane files, 287 tests passed.
  • Focused Telegram progress/finalization/rotation plus ask-user and turn-ledger owners, 342 tests passed across four shards.
  • P1 Codex autoreview clean, no actionable findings.
  • Production delta for this follow-up: +26/-28 (net -2); tests: +84/-1.
  • check:changed passed through core production/tests and all guards, then hit an unrelated stale linked-worktree dependency mismatch in ACPX (acpx 0.13.0 installed vs 0.13.1 locked). Exact-head CI is attached and running with a fresh install.

The optional deterministic real-adapter failpoint proof was not staged: current Crabline accepts valid Telegram edits and has no edit-failure injection surface, so an exact run needs a temporary proxy, mock fixture, and scenario. The focused dispatcher regression is the authoritative proof for the internal partial-delivery contract.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 20, 2026
@steipete
steipete merged commit 53bd316 into main Aug 20, 2026
234 checks passed
@steipete
steipete deleted the steipete/fix-telegram-streamed-questions branch August 20, 2026 02:15
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
* fix(telegram): finalize streamed questions in place

* test(telegram): align partial question delivery coverage

* fix(telegram): propagate partial question finalization

* test(telegram): assert typed partial delivery error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: telegram Channel integration: telegram maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

1 participant