Skip to content

fix(telegram): route commentary through one frozen progress owner - #128259

Merged
steipete merged 2 commits into
openclaw:mainfrom
Parker-Fawcett:fix/telegram-commentary-owner
Aug 26, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
Parker-Fawcett:fix/telegram-commentary-owner

Conversation

@Parker-Fawcett

@Parker-Fawcett Parker-Fawcett commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #128038

AI-assisted: yes — built with Claude; prompts/session logs available on request.

What Problem This Solves

With richMessages + streaming.mode="progress" + streaming.progress.commentary=true, every completed assistant commentary preamble appeared twice in the Telegram progress draft (#128038): once through the draft projection and again through the durable commentary path, because both stayed enabled for the same turn.

Why This Change Was Made

Telegram never supplied the optional shouldDeliverCommentaryPayloads owner callback that #121009 added for Slack/Discord, so resolveTurnCommentaryProgressOwner defaulted durable commentary delivery to enabled while the Telegram draft also rendered each preamble as an interleaved 💬 line. Core's own verbose-visibility decision was frozen per run, but Telegram's draft-side visibility slot remained live, so the two projections could disagree within one turn.

This wires the missing callback in extensions/telegram/src/bot-message-dispatch-turn.ts, gated exactly on when the compositor can render interleaved commentary lines (streamMode === "progress" && commentaryProgressEnabled) and reading the same verboseProgressActive slot that core freezes at turn start and re-resolves per admitted follow-up. This mirrors Discord's wiring in message-handler.process-progress.ts.

  • Commentary draft enabled → callback present; when frozen visibility is false, core suppresses durable delivery and the draft is the single owner; when true, handleItemEvent already yields early and the durable lane delivers.
  • Commentary disabled (commentaryProgressEnabled === false) → callback stays undefined; today's durable-only CLI-commentary path is unchanged (bot-message-dispatch.progress-lifecycle.test.ts still asserts this).

User Impact

One visible copy per completed commentary item during tool-heavy turns. Progress messages no longer grow by repeating status text, keeping long-running work readable in Telegram.

Evidence

Local, current main base 67613e73:

  • New regression tests fail pre-fix: with the fix stashed, bot-message-dispatch.progress-updates.test.ts reports 1 failed (owner-callback assertion); restored fix → green.
  • Post-fix targeted suites: bot-message-dispatch.progress-updates.test.ts 30/30, plus full dispatch surface 251/251 across 17 suites (pnpm test extensions/telegram/src/bot-message-dispatch), re-run green after rebase (41/41 across the two touched suites).
  • Owner-contract coverage mirrors Discord's: frozen getter returns false initially, tracks onVerboseProgressVisibility, draft renders exactly one copy when it owns commentary and nothing when the durable lane owns it.
  • tsgo -p extensions/telegram/tsconfig.json --noEmit clean; oxlint (262 rules) and oxfmt clean on both changed files.

Known proof gap: full tsgo:extensions:test / core lanes were not completable locally (host CPU saturation); CI covers those lanes.

Mock-gateway harness verdict (authorized lane)

Ephemeral topology, all local, no private data in any payload:

  • Gateway: real OpenClaw gateway process (dist-backed gateway run --allow-unconfigured), loopback :19091, isolated OPENCLAW_STATE_DIR, PR head 4a51b972.
  • Channel: Telegram channel pointed at a mock Bot API via the documented channels.telegram.apiRoot; every bot-visible call captured to JSONL.
  • Provider: scenario-aware mock OpenAI Responses server; the inbound prompt triggers its built-in scripted turn — phase-tagged commentary message item + exec tool call, then the final answer after the tool result.
  • Session config: verboseDefault: "on", richMessages: true, streaming.mode: "progress", streaming.progress.commentary: true — the exact repro configuration from [Bug]: Telegram progress draft repeats each commentary update twice #128038.

Complete outbound Bot API traffic for the turn:

sendRichMessage {"chat_id":"777000","rich_message":{"blocks":[{"type":"paragraph","text":"💬 Checking the workspace before answering."}]}}
sendRichMessage {"chat_id":"777000","rich_message":{"blocks":[{"type":"paragraph","text":"🛠️ Exec"}]}}
sendRichMessage {"chat_id":"777000","rich_message":{"blocks":[{"type":"paragraph","text":"OPENCLAW_E2E_DRAFTPROOF"}]}}

Verdict: exactly one visible copy of the completed commentary preamble across all outbound traffic; zero duplicated payloads; 2 model requests (commentary+toolcall, then final); final answer delivered.

{"scenario":"telegram-commentary-one-owner","head":"4a51b972","counts":{"commentarySentenceVisibleCopies":1,"duplicateCopiesOfAnyPayload":0,"modelRequests":2,"finalAnswerDelivered":true},"assertion":"PASS"}

Scope note: steady-state runs render a single copy on unfixed main too — the defect repaired here is the mid-turn visibility race where draft projection and durable delivery could each project the same preamble. The unit suites prove that frozen-owner contract differentially (regression tests fail pre-fix); this verdict proves the changed path end-to-end through a real gateway process, real channel transport, and real HTTP provider renders exactly one visible copy.

Telegram progress mode enabled both the commentary-capable draft and
durable commentary payloads without supplying the shared
shouldDeliverCommentaryPayloads owner callback, so core defaulted
durable delivery on while the draft also rendered each completed
preamble (openclaw#128038). Wire the callback to the same verbose-visibility
slot core freezes at turn start, gated exactly when the compositor can
render interleaved commentary lines, mirroring the Slack/Discord
wiring from openclaw#121009. Commentary-disabled configs keep today's
durable-only path unchanged.

Closes openclaw#128038

AI-assisted (Claude); regression tests fail pre-fix and pass post-fix.
@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S labels Aug 23, 2026
@Parker-Fawcett
Parker-Fawcett marked this pull request as ready for review August 23, 2026 15:48
@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. P2 Normal backlog priority with limited blast radius. 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 Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 11:52 PM ET / August 26, 2026, 03:52 UTC.

ClawSweeper review

What this changes

This PR makes Telegram progress streaming select either the draft or durable delivery lane for each commentary preamble, with regression coverage for both ownership states.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open for normal landing. The patch wires Telegram into the existing frozen one-owner contract, and its focused tests plus isolated gateway/transport proof support the intended single visible commentary copy; it needs an exact-current-main refresh before merge.

Priority: P2
Reviewed head: 82ff10ab8d89e739dcb0c8db59ccf28c7fd916ed

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch follows the established ownership contract and has focused regression and gateway-harness proof.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides an isolated real gateway, mock Bot API, and provider trace showing exactly one visible commentary copy and a delivered final answer.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides an isolated real gateway, mock Bot API, and provider trace showing exactly one visible commentary copy and a delivered final answer.
Evidence reviewed 6 items Telegram callback wiring: The changed reply options supply the existing owner callback only when Telegram progress commentary can render a draft, while retaining the durable-only path otherwise.
Shared owner contract: Core freezes the callback result, enables durable commentary only when it returns true, and marks the draft owner otherwise.
Sibling implementation: Discord uses the same conditional callback and frozen visibility handoff, supporting reuse instead of Telegram-specific delivery policy.
Findings None None.
Security None None.

Live Verification

Command: pnpm test extensions/telegram/src/bot-message-dispatch.progress-updates.test.ts

Result: FAIL (failed) — step 1 run pnpm test extensions/telegram/src/bot-message-dispatch.progress-updates.test.ts: previous terminal command was still running after 30 seconds: "pnpm test extensions/telegram/src/bot-message-dispatch.progress-updates.test.ts"

$ node --import tsx scripts/test-projects.mts extensions/telegram/src/bot-message-dispatch.progress-updates.test.ts
[test] starting test/vitest/vitest.extension-telegram.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-128259-zAtLo0/target

Assertions:

  • FAIL expect_output: freezes the durable commentary owner

How this fits together

Telegram receives agent commentary through the shared reply dispatcher, which decides whether a progress draft or a durable message owns each update. That decision determines what the user sees in the active Telegram progress message.

flowchart LR
A[Model commentary event] --> B[Shared reply dispatcher]
B --> C[Frozen visibility decision]
C --> D{Commentary owner}
D -->|Draft| E[Telegram progress draft]
D -->|Durable| F[Telegram durable delivery]
E --> G[One visible preamble]
F --> G
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as behind main, so the delivery-owner behavior should be revalidated on an exact current-main head before merge.
  • Resolve merge risk (P1) - The bug fix adds six production lines; they should remain limited to this existing callback handoff rather than growing a Telegram-specific ownership path.
  • Complete next step (P2) - No repair lane is needed; this contributor PR is a coherent implementation awaiting rebase refresh, exact-head CI, and normal maintainer merge handling.
Agent review details

Security

None.

PR surface

Source +6, Tests +84. Total +90 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 0 +6
Tests 1 84 0 +84
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 90 0 +90

Review metrics

Metric Value Why it matters
Production versus test delta production +6, tests +84 The production growth wires one existing callback; the remaining change is focused regression coverage for Telegram ownership states.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #128038
Summary: This PR is the explicitly linked candidate fix for the Telegram duplicate-commentary report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Mantis proof suggestion

A Telegram Desktop recording would directly show the one-copy progress-message result under the reported configuration. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify that a progress-streaming commentary preamble appears once, not in both the draft and durable lanes.

Merge-risk options

Maintainer options:

  1. Refresh against current main (recommended)
    Rebase or refresh this PR and require exact-head checks so the selected draft-versus-durable owner is validated against current delivery behavior.

Technical review

Best possible solution:

Retain the shared frozen-owner callback, rebase onto current main, and land only after exact-head validation confirms one visible commentary projection per preamble.

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

Yes—source establishes the prior path enabled both the Telegram draft projection and durable commentary without the shared owner callback; the PR tests exercise each frozen ownership result.

Is this the best way to solve the issue?

Yes—the PR reuses the shared Slack/Discord one-owner contract rather than creating a Telegram-specific delivery policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 345cfde43dc9.

Labels

Label justifications:

  • P2: This repairs duplicate Telegram progress output with bounded user-visible impact.
  • merge-risk: 🚨 message-delivery: The change selects whether commentary is delivered through the Telegram draft or durable-message lane.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 PR body provides an isolated real gateway, mock Bot API, and provider trace showing exactly one visible commentary copy and a delivered final answer.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides an isolated real gateway, mock Bot API, and provider trace showing exactly one visible commentary copy and a delivered final answer.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The fix changes the visible contents of Telegram progress messages.

Evidence

What I checked:

Likely related people:

  • RomneyDa: Authored the merged one-owner commentary contract that this Telegram wiring consumes. (role: shared-contract author; confidence: high; commits: 83d53044a4a3; files: src/auto-reply/reply/commentary-progress-owner.ts)
  • steipete: Authored the current-head commit expanding Telegram commentary-ownership coverage. (role: recent Telegram test contributor; confidence: medium; commits: 82ff10ab8d89; files: extensions/telegram/src/bot-message-dispatch.progress-updates.test.ts)

Rank-up moves

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

  • Rebase or refresh against current main and let exact-head checks complete before merge.

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 (4 earlier review cycles)
  • reviewed 2026-08-23T15:55:44.057Z sha 4a51b97 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-23T16:39:04.976Z sha 4a51b97 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-24T19:29:12.296Z sha 4a51b97 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-24T22:15:06.581Z sha 4a51b97 :: needs maintainer review before merge. :: none

@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 Aug 24, 2026
@steipete
steipete merged commit 9234b9f into openclaw:main Aug 26, 2026
127 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 26, 2026
…enclaw#128259)

* fix(telegram): route commentary through one frozen progress owner

Telegram progress mode enabled both the commentary-capable draft and
durable commentary payloads without supplying the shared
shouldDeliverCommentaryPayloads owner callback, so core defaulted
durable delivery on while the draft also rendered each completed
preamble (openclaw#128038). Wire the callback to the same verbose-visibility
slot core freezes at turn start, gated exactly when the compositor can
render interleaved commentary lines, mirroring the Slack/Discord
wiring from openclaw#121009. Commentary-disabled configs keep today's
durable-only path unchanged.

Closes openclaw#128038

AI-assisted (Claude); regression tests fail pre-fix and pass post-fix.

* test(telegram): cover commentary ownership across streaming modes

---------

Co-authored-by: Parker Fawcett <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
vincentkoc added a commit that referenced this pull request Aug 26, 2026
* origin/main: (24 commits)
  fix(gateway): reject rootless session permission modes (#128149)
  docs(memory): document shipped turn-taint propagation for network tool output (#129837)
  fix(ui): pool reply-less wake activity into one chat rollup (#128442)
  fix(package): prevent installs from deleting validated runtime assets (#129724)
  fix(nodes): approve silent initial node surfaces and name the pending surface approval (#129795)
  fix(backup): preserve configured agent state roots (#129773)
  fix(ui): own chat history issuance with a closed state machine (#129776)
  fix(cron): preserve cancellation reason after late finalization (#129331)
  fix(cron): prevent run waits from failing after clock changes (#129805)
  fix(telegram): route commentary through one frozen progress owner (#128259)
  fix(release): start approved VCR mirror recovery jobs (#129829)
  test: complete current-plugin-metadata-snapshot mock factories (#129791)
  test(telegram): remove duplicate reaction case (#129848)
  fix(channels): honor supported account reply-threading policies (#129679)
  refactor(cli): deduplicate lazy subcommand registration (#129351)
  fix(ai): report interrupted local-model streams instead of empty success (#129794)
  refactor(cli): consolidate Gateway fallback and hook ownership (#129802)
  fix(qa): reject token confidence lanes without executed evidence (#129830)
  fix(tui): fence session state and delayed actions (#129810)
  fix(control-ui): keep task progress full width on hover (#129832)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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 progress draft repeats each commentary update twice

2 participants