Skip to content

fix(matrix): show reasoning when explicitly enabled - #149906

Closed
zhangguiping-xydt wants to merge 20 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/issue-discovery-20260916
Closed

zhangguiping-xydt wants to merge 20 commits into
openclaw:mainfrom
zhangguiping-xydt:fix/issue-discovery-20260916

Conversation

@zhangguiping-xydt

@zhangguiping-xydt zhangguiping-xydt commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Related: #81892

What Problem This Solves

Fixes completed model reasoning being silently suppressed on Matrix after an authorized user enables it, including queued followups, while preventing model-inferred defaults from disclosing reasoning without an explicit preference.

User Impact

Authorized, explicitly enabled reasoning appears as quiet m.notice messages with empty mentions. Missing, off or stream preferences do not grant completed-reasoning display. Ordinary answers continue normally. Committed off changes and lost source-turn authority suppress unsent reasoning.

The optional SDK visibility reader, reply opt-in and outbound capability still require maintainer acceptance of the public contract. There is no persisted schema, dependency or operator configuration migration. Streaming reasoning is outside this change.

Why This Change Was Made

One producing-turn policy follows direct dispatch, native queue custody and the final Matrix SDK handoff. It accepts explicit inline/session/agent/global choices separately from model execution defaults. Existing session identity, revision, cancellation, revocation and writer checks remain in force. Guarded reasoning stays live-only and outside replayable outbound intents and ordinary confirmed-history callbacks; previews and ordinary answers retain their owners.

The explicit-choice repair fixes the review's explicit-opt-in finding using the existing visibility owner. It changes two production files (+11/-4); the whole PR is the completed explicit-on Matrix feature across direct and queued paths. No second policy owner, persistence manager or test-only production hook is added.

CI repair

Current candidate: 6bd643b07c97c1a18fb2c206dcd7f8ad9142d2d8 (parent 7e6a350b). The repair changes only the cleanup lifecycle test and a dedicated allocation for its three added test lines; all previous production changes are unchanged.

The retry test now closes the shared-state worker before taking over the clock and resets its queued attachment-cleanup mock in finally. If the timer assertion exits early, the following test no longer inherits an unconsumed blocking mock. Existing assertions and timeouts remain intact. The extra timer's original hosted source was not naturally reproduced; the worker-close ordering follows the same policy fixture already used nearby.

The complete modified lifecycle file passed 214 tests on this committed candidate (248.9 seconds wall time including worker compilation; 65.86 seconds Vitest duration). Affected agent/session test types, typed lint, formatter parity and the test-line ratchet passed. The initial instrumented diagnosis passed the three cleanup cases but failed a different requester-agent assertion; that diagnostic is retained, and its passing final replay is not claimed as a causal fix. Original Matrix-focused evidence below is reused only for unchanged source inputs.

The exact committed source CLI build passed using the supported declaration-skip option. A fresh real Gateway / real agent / normal model-fallback / installed Matrix SDK / HTTP run with synthetic external services confirmed global explicit-on produces one quiet reasoning notice and one ordinary answer. Public channel stop, 112 seconds of SDK quiet, and host stdin EOF ended in natural Gateway exit 0 without forced termination. The local homeserver recorded a disconnected long-poll response during channel stop; the behavior and teardown assertions passed. This reruns one positive control; the other unchanged-source controls below retain their original execution identities.

An independent Codex source review inspected the complete final 77-file diff and relevant owners with no actionable findings. Reviewed base 72e8e422, head 6bd643b0; canonical diff SHA-256 e241483c84445361aef46f250b6c564dec0d1cbfc557a4a22d50968b3e3f4729. This source review does not substitute for hosted CI or maintainer acceptance.

The original restart timeout was localized to resume:2:stream after SIGKILL, following successful SIGTERM and managed-restart cycles. The fresh hosted merge includes main’s related fixes #192501 and #193730; this repair does not rebase or change restart production code. The restart job executed all five cases successfully, including the previously failing blocked store: false case in 70.462 seconds. This establishes a passing current merge, without retroactively attributing the prior-head timeout.

Hosted CI run 42334091119 tests merge 6cd775a4f850f4236a6b016787d0bc10655812ed, whose parents are main 5cbe1abda85de6db54f01ac99897c2ba00a426b9 and candidate 6bd643b07c97c1a18fb2c206dcd7f8ad9142d2d8. The cleanup job passed both previously failed cases: stale cleanup retry (9 ms) and detached attachment cleanup recovery (8 ms). The CI workflow completed successfully: 70 jobs passed, 27 skipped, zero failures. All nine current-head pull_request workflows completed successfully, including Darwin tooling, CodeQL, critical quality and runtime conformance. The original failed PR-context check was corrected by restoring the required ## Evidence heading and superseded by successful same-head run 42334161235. Maintainer SDK acceptance remains separate.

Evidence

The feature proof below retains its original execution identity; the current-commit CI repair and fresh positive control are recorded above.

Exact candidate: 7e6a350b4b787cc6ea0d6e0cfafffee34d718747, reviewed against 72e8e42210d1bf5f69d0384c84baec0188743337.

Explicit-choice regression, through the actual built Gateway, agent, model fallback, installed Matrix SDK and final HTTP: a fresh session has no inline or persisted reasoning/thinking preference. The primary MiniMax M2.7 request returns model-not-found over HTTP; normal fallback executes M3.1 Flash with its supported thinking level. The external model and homeserver are synthetic fixtures.

Configuration Parent 5ee9ba03 reasoning / answer HTTP Candidate 7e6a350b reasoning / answer HTTP
No reasoning preference 1 / 1 (reproduced defect) 0 / 1
Global reasoningDefault: "on" — 1 / 1
Global off, agent reasoningDefault: "on" — 1 / 1

The direct M2.7/off route alone did not reproduce disclosure because another producer guard suppressed reasoning. The fallback route above does reproduce it; no provider resolver, execution default or fallback behavior was changed to manufacture the result.

Queued behavior rerun on the same candidate: public Matrix /status observed depth 0→1 behind a held model request before each queued turn began.

Queued turn Reasoning HTTP Ordinary answer HTTP
Authorized, explicitly enabled 1 quiet notice 1
Reasoning disabled before releasing the held turn 0 1
Sender without command authority 0 1

The off change committed before release and before the queued model request. Returned ordinary source-history text excludes reasoning markers; native structured thinking remains in the model transcript.

All four executions (three configuration controls and one three-scenario queue run) used public channels.stop, a verified stopped Matrix runtime and at least 112 seconds of HTTP quiet to retire existing SDK deadlines. Documented host stdin EOF then produced natural Gateway exit 0 and a clean receipt, without forced termination, warnings, residual owned descendants or unjoined fixture threads. This qualifies staged teardown; direct whole-Gateway cancellation of referenced SDK timeout handles remains unqualified.

Focused checks and review:

  • The absent-preference owner regression failed on the parent (1 failed / 24 passed) and passes on the candidate. Current suites: visibility owner 25, producer 4, plugin reader 1 and model-level resolver 4 tests passed.
  • Formatting, typed lint, core and affected messaging/plugin test type graphs, and exact-base line-cap, test-growth and mock-export checks passed. The dedicated test allocation is 2220, matching net test growth; the shared scalar is unchanged. Checks executed on the identical staged source tree, then byte hashes were checked against the clean commit before reuse.
  • The clean committed CLI bundle built through the supported declaration-skip option. Runtime provenance checks bind the bundle's input signature, tree and commit. This is not a full release/package/declaration build.
  • An independent Codex source review inspected the complete 75-file committed diff and relevant owners: no actionable correctness finding. This source-only review does not certify runtime, CI or maintainer approval. Canonical diff SHA-256: 267fbbe15caed1b272a8c8f9034449bc9a33837ecf14303d91c79e09fa5ba6f4.
  • Changed-file wall times, including worker compilation: owner 175.9s, producer 203.6s, plugin reader 177.2s. Resolver regression: 166.1s. Hosted CI details for this exact head are recorded below.

Remaining boundaries: the original broad queue driver still reports PARTIAL_PROOF / exit 2 for supplementary cross-destination history; a separate qualifier preserves that result and qualifies only the three retained-queue-to-HTTP scenarios and clean teardown. Ordinary source-history exclusion does not establish positive durable answer persistence in a different destination. These fixtures do not qualify a live tenant, E2EE or a real inference service. Maintainer SDK acceptance, hosted CI and review labels remain separate.

Hosted review inspected at closeout: ClawSweeper revision 22, reviewed at 2026-11-04 03:08 UTC on 7e6a350b, reports no actionable code or security findings, sufficient bounded behavior proof (5/6), and complete fix scope. It remains blocked before merge on public SDK acceptance and unresolved CI attribution. The earlier waiting-on-maintainer label was removed; there is no ready-for-maintainer-look label. Acceptance of the public visibility reader, reply opt-in and outbound capability remains an explicit maintainer decision. No merge approval is claimed.

CI run 41762256595 completed on merge 95093b3b into main 73591122: 69 jobs succeeded, 27 were skipped, and 3 failed. Two are test-job failures; the third is their aggregate openclaw/ci-gate. Production types and baseline ratchets passed.

  • Subagent lifecycle cleanup shard: two assertions failed (one timer expected, two observed; false expected, true observed in cleanup recovery).
  • Gateway restart/resume test: the graceful-shutdown case with blocked store: false timed out at 180 seconds. Captured output includes store-target collisions, pending startup admission and a skipped restart resume; the other three hosted cases passed.

The affected test files are byte-identical at the CI main base, merge and PR head, and the cleanup implementation is unchanged base-to-merge. The pipeline failure report classifies both jobs unknown, with no matching scheduled-main job. Earlier-head MCP/type and test-budget diagnoses do not apply to this run.

Bounded baseline diagnosis: an independent snapshot of exact main 73591122 was verified against its complete Git tree fad0f1f5e57b41e296f45b8aabf6e60b444bdb2d; package/lock/workspace/Bun-pin inputs match. Tests ran serially under the same pinned Bun in a secretless, network-isolated container.

Baseline selection Observed result Limit
Full subagent lifecycle file 214 passed; outer exit 0, including both hosted-failed assertions Focused base run did not reproduce the failure; inter-file and transitive effects remain unresolved.
Full Gateway restart file Two different cases (SIGKILL/partial shutdown and principal-authority loss) reached 180-second timeouts; bounded diagnostic then interrupted, outer exit 143 Partial diagnosis: the hosted failing unblocked-store case was not established. No passing replay, inherited-failure, environment-cause or clean-teardown claim.

All 63,635 tracked baseline blobs still matched after the diagnostic and its container was stopped. These baseline results do not certify the PR candidate. That prior-head CI remained failed and attribution unresolved. No failed check was suppressed or represented as passing, and no empty commit or blind CI rerun was used. Public SDK acceptance remains a separate maintainer decision.

@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: matrix Channel integration: matrix labels Sep 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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. labels Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR delivers explicitly enabled completed reasoning as quiet Matrix notices across direct and queued replies.

Example: An authorized Matrix user sends /reasoning on and asks a reasoning-capable model a question.

  • Before: Only the ordinary answer appears in Matrix.
  • After: Completed reasoning appears separately as an m.notice with empty mentions, followed by the ordinary answer.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused behavior is proven and no actionable patch defect was found; public-contract direction remains unsettled and required CI is red.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Current-head results exercise the built Gateway through agent execution, fallback, installed Matrix SDK, and final HTTP: explicit on delivers a quiet notice, absent preference does not, and disabled or unauthorized queued turns send only ordinary answers; synthetic external services limit claims to this boundary rather than live tenants or E2EE.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Matrix users receive no completed reasoning after explicitly enabling it.
Reason: Restoring the documented on-mode behavior has clear value, but the proposed public SDK contract requires owner acceptance.

Merge readiness

⛔ Blocked before merge - 3 items remain

This PR addresses a current Matrix bug and has sufficient bounded behavior proof; SDK contract acceptance and unresolved CI failures still block merging.

Priority: P2
Reviewed head: 7e6a350b4b787cc6ea0d6e0cfafffee34d718747
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should the Plugin SDK expose this reasoning visibility reader, reply opt-in, and outbound capability as a supported public contract?
  • Recommendation: Accept the narrow contract: Approve the documented host-owned visibility reader and live-only delivery obligations.
  • Why: The bug is established, but neither the discussion nor recorded approvals accepts the new public delivery contract.

Before merge

  • Resolve merge risk - Before merge, the maintainer must resolve attribution of the failing restart/resume and subagent lifecycle checks and satisfy the required CI gate.
  • Await maintainer action - The SDK owner must approve or narrow the proposed public reasoning-delivery contract.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

Core reply execution produces reasoning payloads; producing-turn visibility, queue custody, and Matrix transport checks determine whether those payloads reach a room.

flowchart LR
A[Authorized Matrix input] --> B[Core reply execution]
B --> C[Producing turn visibility]
C --> D[Direct or queued delivery]
D --> E[Matrix final authority check]
E --> F[Quiet reasoning notice]
D --> G[Ordinary answer]
Loading

Technical review

Best possible solution:

Accept a narrow host-owned visibility contract that delivers explicit on-mode reasoning through existing queue and Matrix transport owners while preserving ordinary-answer privacy and durability.

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

Current-main source shows both missing lane opt-in and unconditional Matrix suppression, corroborated by the linked official-release report; this review ran no reproduction.

Is this the best way to solve the issue?

The smallest complete fix binds explicit display permission to the producing turn and carries it through existing queue and transport owners, which this patch implements without removing ordinary reasoning sanitization.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 35f1c997985e.

Merge-risk options

Maintainer options:

  1. Establish CI causation (recommended)
    Compare the failing scenarios on the CI base and candidate, then repair any demonstrated PR-caused failure.

Provenance checked

  • Matrix reasoning suppression changes intended behavior with a stated reason (1298bd4: Prevent internal thinking traces from reaching Matrix rooms without a dedicated reasoning lane; later privacy hardening is recorded in fix(matrix): prevent private reasoning from reaching rooms #115553.)
  • Reasoning preference authorization keeps the original intent (0c9f844: Support configured defaults while preserving override order and authorization for reasoning state.)
  • Reply normalization and plugin veto keeps the original intent (dd55770: Preserve authoritative plugin suppression across delivery paths rather than resurrecting rejected payloads.)
  • Queue lifecycle ownership keeps the original intent (36e277d: Give each session one controller for turns, queues, and Stop; visibility cleanup is attached to that existing source lifecycle.)
  • Confirmed outbound history keeps the original intent (3fe7f1e: Record ordinary cross-chat messages through one history owner; guarded reasoning remains outside ordinary confirmed-answer history.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +604, Tests +2221, Docs +37, Other +2. Total +2864 across 75 files. Added test files: 4.

View PR surface stats
Area Files Added Removed Net
Source 41 662 58 +604
Tests 30 2267 46 +2221
Docs 2 37 0 +37
Config 0 0 0 0
Generated 0 0 0 0
Other 2 3 1 +2
Total 75 2969 105 +2864

Labels

Label changes:

  • remove status: ⏳ waiting on maintainer: Current PR status no longer selects a status label.

Label justifications:

  • P2: Explicitly requested reasoning is unavailable on Matrix while ordinary answers remain functional.
  • merge-risk: 🚨 compatibility: The additive Plugin SDK surface establishes ongoing visibility, metadata-preservation, and live-delivery obligations for channel plugins.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (21 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-17T08:17:22.739Z sha 650ce42a8232971f49247fa18bc5cfe2e923bf3d :: blocked before merge. :: none
  • reviewed 2026-10-06T01:41:28.468Z sha 650ce42a8232971f49247fa18bc5cfe2e923bf3d :: blocked before merge. :: none
  • reviewed 2026-10-06T01:51:28.856Z sha 650ce42a8232971f49247fa18bc5cfe2e923bf3d :: blocked before merge. :: none
  • reviewed 2026-10-18T00:48:44.929Z sha 39b6c22bbd9913a2996c2954d6dd732559a962bd :: needs real behavior proof before merge. :: [P2] Repair the CLI sink fixtures for wrapped callbacks
  • reviewed 2026-10-26T12:44:38.342Z sha d05dfbb :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-03T23:31:35.879Z sha 5ee9ba0 :: blocked before merge. :: [P1] [P1] Require an explicit preference before authorizing reasoning
  • reviewed 2026-11-04T02:49:38.836Z sha 7e6a350 :: blocked before merge. :: none
  • reviewed 2026-11-04T02:59:51.821Z sha 7e6a350 :: blocked before merge. :: none

Reviewed November 3, 2026, 10:08 PM ET / November 4, 2026, 03:08 UTC (Revision 22).

@zhangguiping-xydt
zhangguiping-xydt marked this pull request as ready for review September 16, 2026 09:00
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. and removed 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. labels Sep 16, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 16, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 16, 2026
@zhangguiping-xydt
zhangguiping-xydt force-pushed the fix/issue-discovery-20260916 branch from 82e3dc7 to d05dfbb Compare October 26, 2026 11:53
@zhangguiping-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 26, 2026
@zhangguiping-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 3, 2026
@zhangguiping-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The explicit-opt-in finding is repaired in 7e6a350. The PR body now includes the reproduced parent fallback disclosure, exact-candidate no-preference and global/agent-on controls, refreshed native queued cases, clean teardown, focused checks and independent complete-diff source review. Hosted CI is still pending; SDK contract acceptance remains a maintainer decision.

@clawsweeper

clawsweeper Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 4, 2026
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: matrix Channel integration: matrix docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: file-transfer proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant