Skip to content

fix(telegram): deliver reasoning lane under /reasoning on#95040

Closed
wendy-chsy wants to merge 1 commit into
openclaw:mainfrom
wendy-chsy:fix/telegram-reasoning-on-delivery
Closed

fix(telegram): deliver reasoning lane under /reasoning on#95040
wendy-chsy wants to merge 1 commit into
openclaw:mainfrom
wendy-chsy:fix/telegram-reasoning-on-delivery

Conversation

@wendy-chsy

@wendy-chsy wendy-chsy commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • When /reasoning on is active, thinking content (type:thinking parts) from reasoning models was silently dropped in Telegram.
  • The root cause is that normalizeDeliveryPayload suppresses payloads with isReasoning: true via shouldSuppressReasoningPayload.
  • /reasoning stream worked because ephemeral streaming bypassed this path.
  • This fix intercepts reasoning payloads before normalization and delivers them directly through the reasoning lane.

Linked issue

Closes #94937

Real behavior proof

  • Behavior or issue addressed: Telegram drops thinking content under /reasoning on for reasoning models. This fix delivers isReasoning payloads directly through the reasoning lane before normalization suppresses them.
  • Real environment tested: Unit tests pass (see below). Live Telegram verification is pending — I do not have a running Telegram bot environment for this proof.
  • Exact steps or command run after this patch:
    1. pnpm build — clean
    2. pnpm test extensions/telegram/src/bot-message-dispatch.test.ts — 129 passed
    3. pnpm test extensions/telegram/src/reasoning-lane-coordinator.test.ts — 5 passed
    4. pnpm test extensions/telegram/src/lane-delivery.test.ts — 41 passed
    5. pnpm test extensions/telegram/src/send.test.ts — 132 passed
  • Evidence after fix: Unit tests confirm the reasoning lane delivery path works correctly. Telegram live proof can be captured via Mantis (see comment below).
  • Observed result after fix: Reasoning payloads bypass normalizeDeliveryPayload suppression and are delivered through the reasoning lane coordinator.
  • What was not tested: Live Telegram bot end-to-end with a real reasoning model response. The delivery path requires a Telegram bot token and a running OpenClaw instance with a reasoning model provider.

Tests and validation

' pnpm test extensions/telegram/src/bot-message-dispatch.test.ts -> 129 passed pnpm test extensions/telegram/src/reasoning-lane-coordinator.test.ts -> 5 passed pnpm test extensions/telegram/src/lane-delivery.test.ts -> 41 passed pnpm test extensions/telegram/src/send.test.ts -> 132 passed pnpm build -> clean '

Risk checklist

  • User-visible behavior change: Yes - thinking now appears under /reasoning on
  • Config/default surface change: No
  • Security/audit impact: No
  • New dependency: No
  • Migration needed: No

AI-assisted code generation used for this fix.

Reasoning blocks from the reply pipeline carry isReasoning=true and are
suppressed by normalizeDeliveryPayload via shouldSuppressReasoningPayload.
Deliver them through the reasoning lane before the normalizer runs, so
thinking persists as messages when /reasoning on is active (/reasoning
stream worked because ephemeral streaming bypassed this path).

Fixes openclaw#94937

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 19, 2026
@clawsweeper

clawsweeper Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Current main already contains the fuller Telegram durable-reasoning fix from the merged canonical PR, including shared-dispatch opt-in, Telegram marker stripping before outbound normalization, and regression coverage, so this narrower branch is no longer necessary.

Root-cause cluster
Relationship: superseded
Canonical: #97875
Summary: The current PR is an older candidate for the Telegram /reasoning on durable-thinking loss, and the same central problem is now fixed on current main by the merged canonical PR.

Members:

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

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the merged current-main fix from #97875 as the canonical implementation and close this narrower partial branch.

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

Yes. The linked issue provided concrete /reasoning on Telegram steps, and source inspection showed the old shared-dispatch and outbound-normalization suppression path; current main now has regression tests for the fixed path.

Is this the best way to solve the issue?

No for this branch. The current-main fix is the better solution because it passes reasoning through shared dispatch with an explicit opt-in, strips the marker only before Telegram normalization, preserves generic-channel suppression, and adds focused tests.

Security review:

Security review cleared: The PR diff only changes Telegram TypeScript dispatch logic and does not touch secrets, dependencies, workflows, package metadata, generated artifacts, or install/build execution paths.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • fuller-stack-dev: Authored the merged canonical fix that current main now contains for the Telegram durable-reasoning delivery path. (role: canonical fix author; confidence: high; commits: 7e4fc507c30a, a4fd87bd810e, b4fde273df6d; files: extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/bot-message-dispatch.test.ts, src/auto-reply/reply/dispatch-from-config.ts)
  • vincentkoc: Authored a maintainer-labeled overlapping branch for the same Telegram durable reasoning issue and supplied related Testbox evidence before the merged canonical fix landed. (role: earlier candidate-fix author; confidence: medium; commits: 54ab69d23bbb; files: extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/bot-message-dispatch.test.ts, src/auto-reply/reply/dispatch-from-config.ts)
  • Ayaan Zaidi: Recent current-main history touches Telegram dispatcher delivery and visible reply behavior adjacent to the reasoning lane code path. (role: recent Telegram delivery contributor; confidence: medium; commits: dc3b10285db8, 5aad79571ee6; files: extensions/telegram/src/bot-message-dispatch.ts)
  • joshavant: Introduced the centralized outbound payload planner that suppresses marked reasoning payloads unless Telegram strips the marker for lane-owned delivery. (role: outbound planner contributor; confidence: medium; commits: c4764095f859; files: src/infra/outbound/payloads.ts)

Codex review notes: model internal, reasoning high; reviewed against eb417fa206e6; fix evidence: commit 455f813d6ee6, main fix timestamp 2026-06-30T00:31:06Z.

@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 19, 2026
@wendy-chsy

Copy link
Copy Markdown
Contributor Author

@openclaw-mantis telegram desktop proof: verify /reasoning on shows a durable Thinking message and final answer without duplication.

This is a follow-up to the ClawSweeper/Codex review request for real behavior proof (#95040 (comment)). The contributor does not have a live Telegram bot environment. Requesting Mantis to capture real Telegram proof:

  1. Enable /reasoning on in a Telegram chat
  2. Send a message that triggers a reasoning model response
  3. Verify the Thinking lane appears and persists
  4. Verify the final answer appears without duplication

@wendy-chsy

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 23, 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.

@wendy-chsy

Copy link
Copy Markdown
Contributor Author

Proof Report

Change Summary

This PR adds an early-return path in dispatchReplyWithBufferedBlockDispatcher.deliver that intercepts payload.isReasoning === true blocks before they reach normalizeDeliveryPayload (which suppresses them via shouldSuppressReasoningPayload). Reasoning text is delivered directly through the reasoning lane via deliverLaneText, preserving thinking content under /reasoning on.

Unit Test Results

All 4 related Telegram test suites pass on commit a2f9d696:

Suite Tests Status
bot-message-dispatch.test.ts 129 passed ✅ Pass
reasoning-lane-coordinator.test.ts 5 passed ✅ Pass
lane-delivery.test.ts 41 passed ✅ Pass
send.test.ts 132 passed ✅ Pass
Total 307 passed

Test Evidence

$ pnpm test extensions/telegram/src/bot-message-dispatch.test.ts
  Test Files  1 passed (1)
  Tests  129 passed (129)

$ pnpm test extensions/telegram/src/reasoning-lane-coordinator.test.ts
  Test Files  1 passed (1)
  Tests  5 passed (5)

$ pnpm test extensions/telegram/src/lane-delivery.test.ts
  Test Files  1 passed (1)
  Tests  41 passed (41)

$ pnpm test extensions/telegram/src/send.test.ts
  Test Files  1 passed (1)
  Tests  132 passed (132)

Regression Check

  • The existing test "suppresses reasoning-only finals without raw text fallback" still passes — confirming the normal normalizeDeliveryPayload suppression path is unaffected for payloads without isReasoning: true.
  • All reasoning streaming tests pass — confirming the onReasoningStream/streaming path is unaffected.
  • Only pre-existing failure: setup-surface.test.ts (locale string mismatch) — confirmed present on main and unrelated to this change.

Code Analysis

The fix correctly:

  1. Checks payload.isReasoning before normalizeDeliveryPayload would suppress it
  2. Extracts reasoning text via splitTelegramReasoningText(payload.text, true) — the true argument ensures the entire payload text routes to the reasoning lane
  3. Uses the existing deliverLaneText infrastructure for delivery
  4. Properly updates reasoningStepState lifecycle: noteReasoningHint()noteReasoningDelivered()resetForNextStep() (on final)
  5. Returns early after delivery, preventing the normalizer from ever seeing the reasoning payload

Surface Changes

  • Changed files: 1 (extensions/telegram/src/bot-message-dispatch.ts, +24 lines)
  • No config/default surface changes, no new dependencies, no security/audit impact

Live Proof Gap

Live Telegram end-to-end verification with a real reasoning model response still requires a Telegram bot token + running OpenClaw instance with a reasoning model provider. The deliverLaneText path is unit-tested, but the full pipeline (reasoning model → payload.isReasoning → reasoning lane → Telegram message) needs live environment proof (via Mantis/Crabbox).


Proof generated on commit a2f9d696

@wendy-chsy

Copy link
Copy Markdown
Contributor Author

Build Confirmation

Full pnpm build completes cleanly on commit a2f9d696. Build timings: tsdown 440s, plugin-sdk dts 71s, ui 3.5s — total ~9.5 min. No build errors.

@clawsweeper clawsweeper Bot added status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. status: 🛠️ actively grinding The PR author has acted after the latest ClawSweeper review and work remains. labels Jul 1, 2026
@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jul 1, 2026
@wendy-chsy
wendy-chsy deleted the fix/telegram-reasoning-on-delivery branch July 2, 2026 01:51
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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/reasoning on drops the thinking lane on Telegram — renders under /reasoning stream, lost under on

1 participant