Skip to content

fix(telegram): stop duplicate fallback when dispatch fails after final reply#90152

Merged
obviyus merged 1 commit into
openclaw:mainfrom
zhangguiping-xydt:proof-harness
Jul 3, 2026
Merged

fix(telegram): stop duplicate fallback when dispatch fails after final reply#90152
obviyus merged 1 commit into
openclaw:mainfrom
zhangguiping-xydt:proof-harness

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Related: #87299
Related: #89930

What Problem This Solves

Resolves a Telegram late-dispatch boundary where a visible final reply could be followed by a generic error fallback if dispatch cleanup failed afterward.

The branch had also become unmergeable after upstream Telegram dispatch changes. This update rebases the proof harness onto current origin/main, resolves the conflicts, and keeps the fallback suppression tied to final-answer delivery rather than any partial/progress delivery.

Why This Change Was Made

This adds a trusted private-QA proof scenario, --proof-scenario late-dispatch-after-final, and passes it into the local Telegram gateway as OPENCLAW_TELEGRAM_QA_DISPATCH_FAULT=late-dispatch-after-final. The Telegram hook remains gated by OPENCLAW_BUILD_PRIVATE_QA=1, OPENCLAW_ENABLE_PRIVATE_QA_CLI=1, and the exact scenario value.

The proof runner also rejects candidate SUT checkouts that do not contain the matching Telegram QA fault hook, and the Mantis Telegram Desktop prompt tells agents to rebase onto the harness or test a merge result instead of treating an unsupported candidate run as proof. The SUT support guard now checks for the hook in the exported dispatchTelegramMessage dispatch path rather than accepting loose stale strings or fake dispatcher snippets (RF-003). The runtime fallback guard now suppresses duplicate generic fallback only after a final answer has been delivered, while preserving the error fallback after partial-only output failures. Spooled replay completion still treats already visible output as delivered so draft/progress output is not retried unnecessarily.

Maintainers should still decide whether carrying this private-QA runtime hook and trusted proof-runner behavior in bundled Telegram source is acceptable (RF-004, RF-005).

User Impact

Developers and maintainers can now run a deterministic Telegram proof scenario for the late-dispatch-after-final boundary, and proof agents get a clear failure instead of misleading exact-path evidence when a candidate checkout lacks the hook.

Telegram users no longer receive a second generic error reply after a visible final answer is already delivered. If dispatch fails after only partial/block output, the existing terminal error fallback is still sent.

Evidence

Before this update, check-main-drift reported has_conflicts: true and sync-main reproduced conflicts in:

  • extensions/telegram/src/bot-message-dispatch.ts
  • extensions/telegram/src/bot-message-dispatch.test.ts
  • scripts/e2e/telegram-user-crabbox-proof.ts
  • test/scripts/telegram-user-crabbox-proof.test.ts

After resolving the conflicts, check-main-drift reports has_conflicts: false against current origin/main; the updated branch is squashed to a single commit on top of origin/main (RF-002). Validation included the rebased full-file suites before the final focused guard hardening:

$ pnpm exec vitest run extensions/telegram/src/bot-message-dispatch.test.ts
Test Files  1 passed (1)
     Tests  147 passed (147)
  Duration  18.83s

$ pnpm exec vitest run test/scripts/telegram-user-crabbox-proof.test.ts
Test Files  1 passed (1)
     Tests  32 passed (32)
  Duration  4.98s

$ pnpm run check:no-conflict-markers
$ node scripts/check-no-conflict-markers.mjs

Additional focused validation on the current head:

$ pnpm exec vitest run test/scripts/telegram-user-crabbox-proof.test.ts -t "fake dispatcher option block|cleans local SUT children"
Test Files  1 passed (1)
     Tests  2 passed | 31 skipped (33)
  Duration  2.10s

$ pnpm exec vitest run extensions/telegram/src/bot-message-dispatch.test.ts -t "does not return retryable after spooled replay already showed visible output|returns retryable when dispatch fails after partial output and the fallback is not delivered|returns retryable when spooled replay suppresses fallback after non-silent delivery skip"
Test Files  1 passed (1)
     Tests  3 passed | 145 skipped (148)
  Duration  17.68s

$ git diff --check

Current limitations: this PR still does not include a fresh live Telegram Desktop forced late-dispatch capture (RF-001). The intended exact-path consumer remains the downstream Telegram behavior-fix proof after this harness lands or is tested as a merge result.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram scripts Repository scripts size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 4, 2026
@clawsweeper

clawsweeper Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head bc02eefe83f32095ca3fa34dadce362a834de811, but the PR head is now 48e6d6f6cb81cec9fb626566feb399d433c9a260. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

@openclaw-barnacle openclaw-barnacle Bot added triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels Jun 4, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Jun 4, 2026
@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 4, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 4, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 4, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 2, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 2, 2026
@zhangguiping-xydt

Copy link
Copy Markdown
Contributor Author

Live Telegram proof for late-dispatch-after-final on merge commit 6dfe62188024c89b03292b8cfac1717ee18c14a5.

Setup:

  • Local SUT: PR fix(telegram): stop duplicate fallback when dispatch fails after final reply #90152 merge result at 6dfe62188024c89b03292b8cfac1717ee18c14a5
  • Telegram bot: @moongpbot (botId=8034041027)
  • Telegram chat type: private
  • Proof scenario: OPENCLAW_TELEGRAM_QA_DISPATCH_FAULT=late-dispatch-after-final
  • QA gates enabled: OPENCLAW_BUILD_PRIVATE_QA=1, OPENCLAW_ENABLE_PRIVATE_QA_CLI=1
  • Mock model final text: OPENCLAW_LATE_DISPATCH_FINAL_2026-07-03T02-24-01-279Z
  • Real user message sent from local Telegram Desktop: OpenClaw PR 90152 late-dispatch proof 2026-07-03T02-24-01-279Z

Observed result:

  • Telegram Desktop shows exactly one bot reply for this turn, containing the mock final text.
  • No generic Something went wrong while processing your request. Please try again. fallback appears after the visible final reply.
  • The local gateway log confirms the forced late-dispatch fault fired after final delivery:
    2026-07-03T10:24:16.051+08:00 [telegram] final reply failed: Error: telegram qa forced late dispatch error after final delivery
    2026-07-03T10:24:16.056+08:00 [turn/kernel] visible channel turn dispatched with no queued reply payloads: channel=telegram messageId=62 sessionKey=agent:main:main
    
  • The mock model request log contains the exact real Telegram prompt text, proving the real Telegram inbound message reached the SUT before the forced late-dispatch fault.

Sanitized runner summary:

{
  "status": "pass",
  "proofScenario": "late-dispatch-after-final",
  "botUsername": "moongpbot",
  "chatType": "private",
  "requestLogContainsProofText": true,
  "gatewayLogContainsForcedHook": true,
  "requestLogExists": true
}

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 3, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 3, 2026
@zhangguiping-xydt zhangguiping-xydt changed the title Add Telegram late-dispatch proof scenario fix(telegram): stop duplicate fallback when dispatch fails after final reply Jul 3, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 3, 2026
…l reply

Telegram no longer sends a generic "Something went wrong" fallback after a
final answer was already delivered and a later dispatch/cleanup step failed.
Failures with only partial or no visible output still send the error fallback
and stay retryable.

Related: openclaw#87299
Closes openclaw#90152
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed scripts Repository scripts size: L labels Jul 3, 2026
@obviyus

obviyus commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Maintainer takeover: rewrote the branch to a single commit keeping the runtime fix and its behavior tests, and dropping the private-QA parts.

Kept:

  • The fallback/retry/status-reaction guards keyed on finalAnswerDelivered in extensions/telegram/src/bot-message-dispatch.ts — no more duplicate generic fallback after a delivered final answer; partial-only output failures still fall back and stay retryable.
  • Two behavior tests for the partial-output fallback/retry paths.
  • The 1-line reasoning-lane-coordinator.test.ts alignment: that expectation was left stale on main by af0477b (durable 🧠 marker rewrite), so the telegram test lane needs it to pass.

Dropped (maintainer decision — we don't want more env-gated QA fault hooks in bundled plugin runtime code):

  • OPENCLAW_TELEGRAM_QA_DISPATCH_FAULT hook and its call sites in the dispatch path.
  • The late-dispatch-after-final proof-runner scenario, its tests, and the Mantis prompt update.

The live Telegram Desktop proof posted above still stands as evidence for the fix itself. Thanks @zhangguiping-xydt — authorship kept on the squashed commit.

@obviyus
obviyus merged commit 0ad5884 into openclaw:main Jul 3, 2026
98 of 100 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 4, 2026
…l reply

Telegram no longer sends a generic "Something went wrong" fallback after a
final answer was already delivered and a later dispatch/cleanup step failed.
Failures with only partial or no visible output still send the error fallback
and stay retryable.

Related: openclaw#87299
Closes openclaw#90152
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: supplied External PR includes structured after-fix real behavior proof. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants