Skip to content

fix(matrix): deliver explicit reasoning notices - #128254

Closed
gaoanze888 wants to merge 19 commits into
openclaw:mainfrom
gaoanze888:gaoanze888/matrix-reasoning-notices
Closed

gaoanze888 wants to merge 19 commits into
openclaw:mainfrom
gaoanze888:gaoanze888/matrix-reasoning-notices

Conversation

@gaoanze888

@gaoanze888 gaoanze888 commented Aug 23, 2026 •

Copy link
Copy Markdown

Closes #81892

What Problem This Solves

Fixes Matrix reasoning delivery so explicitly tagged reasoning is delivered as Matrix notices instead of being suppressed, while unflagged reasoning-looking text remains hidden.

Why This Change Was Made

Matrix now opts into explicit reasoning payloads and delivers them through a separate notice path. Stream-mode reasoning buffers the latest reasoning text and sends it when the reasoning block ends, without overwriting the active answer draft.

Reasoning notice delivery is tracked by the Matrix reply dispatcher and drained before final reply delivery, so the reasoning notice cannot be overtaken by the final answer. Reasoning notices also suppress Matrix mention metadata, so @room or Matrix IDs inside model reasoning cannot notify room members.

User Impact

Users who enable Matrix reasoning can see explicit reasoning output, including /reasoning stream summaries, while final answer delivery, draft delivery, and Matrix mention safety remain intact.

Evidence

  • pnpm test extensions/matrix/src/matrix/monitor/handler-reply-dispatcher.test.ts extensions/matrix/src/matrix/monitor/replies.test.ts extensions/matrix/src/matrix/send.test.ts
  • pnpm check:changed -- extensions/matrix/src/matrix/send/types.ts extensions/matrix/src/matrix/send.ts extensions/matrix/src/matrix/send.test.ts extensions/matrix/src/matrix/monitor/replies.ts extensions/matrix/src/matrix/monitor/replies.test.ts extensions/matrix/src/matrix/monitor/handler.ts extensions/matrix/src/matrix/monitor/handler-reply-dispatcher.ts extensions/matrix/src/matrix/monitor/handler-reply-dispatcher.test.ts

Safety / ordering proof:

  • explicit reasoning replies call sendMessageMatrix(..., { msgtype: "m.notice", disableMentions: true })
  • Matrix send suppresses m.mentions when disableMentions is true
  • regression test sends @room / @alice:example.org with disableMentions: true and asserts the event remains m.notice with m.mentions: {}
  • dispatcher regression test starts a stream-mode reasoning notice delivery, starts final reply delivery before the notice resolves, and asserts final delivery waits until the reasoning notice resolves before sending the final answer

AI-assisted implementation; I reviewed Matrix reasoning delivery, active-draft behavior, mention handling, ordering, and validation output.

Exact-head Matrix transport proof

On head a90f2c26680913993eacf08d1827b7c1f4f4b42c, a real repository MatrixClient sent events through an isolated loopback HTTP homeserver. The proof exercised createMatrixReplyDispatcher for all three configured reasoning modes and captured the homeserver PUT bodies.

Mode Observed Matrix events, in wire order
off one m.text final; no reasoning event
on one m.notice durable reasoning, then one m.text final
stream one m.notice stream-end reasoning, then one m.text final

Both reasoning notices contained "m.mentions": {} even though the input included @room and a Matrix user ID. The script asserted event counts and mention suppression and exited 0. The access token, loopback port, room ID, and user ID were disposable proof-only values.

Follow-up validation: session-store read errors now fail closed to off, and reasoning notices use one serialized delivery queue. A two-window regression proves both notices complete in source order before the final reply.

@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: matrix Channel integration: matrix size: XS labels Aug 23, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 real behavior proof before merge. Reviewed September 2, 2026, 2:12 PM ET / 18:12 UTC.

ClawSweeper review

What this changes

The branch delivers Matrix reasoning notices according to the resolved visibility mode and serializes them before later reply output.

Merge readiness

⛔ Blocked before merge - 6 items remain

The branch is a credible fix for the linked Matrix reasoning-delivery regression and no introduced correctness defect was found, but it remains unready to merge until a Plugin SDK owner accepts the new public callback and final-head Matrix transport proof covers the added CLI closure boundaries.

Priority: P1
Reviewed head: c2fc8fa7420486388ab83b386d81fe91b82ed0ee
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch has coherent owner-boundary coverage and meaningful tests, but the final head lacks matching real Matrix transport proof.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: Earlier loopback MatrixClient traces exercise the design, but current head c2fc8fa adds CLI reasoning-closure boundaries and lacks an exact-head trace spanning reasoning, tool output, a second reasoning window, and final output. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Earlier loopback MatrixClient traces exercise the design, but current head c2fc8fa adds CLI reasoning-closure boundaries and lacks an exact-head trace spanning reasoning, tool output, a second reasoning window, and final output. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Current-main gap: Current main suppresses typed reasoning replies before Matrix delivery, whereas the PR head formats and sends them as explicit notices; the linked issue's central behavior is therefore not already implemented on main.
Matrix delivery owner: The PR head formats explicit reasoning payloads, bypasses only the historical reasoning suppression, and sends text reasoning with Matrix notice and mention-suppression options.
Ordering owner: Ordinary replies await the serialized reasoning queue, while a stream-end callback appends each reasoning notice to that queue before later delivery.
Findings None None.
Security None None.

How this fits together

Matrix receives agent progress and final replies through its channel plugin. The shared reply runner resolves reasoning visibility and invokes Matrix callbacks, which enqueue Matrix notices before ordinary reply delivery.

flowchart LR
  A[Agent progress] --> B[Shared reply runner]
  B --> C[Resolved reasoning mode]
  C --> D[Matrix delivery queue]
  D --> E[Reasoning notice]
  D --> F[Tool and final replies]
Loading

Decision needed

Question Recommendation
Should onReasoningLevelResolved become a supported general Plugin SDK reply-runtime callback rather than remaining Matrix-specific plumbing? Accept the SDK callback: Approve the documented optional callback as the generic contract, contingent on final-head Matrix transport proof.

Why: The callback is publicly re-exported and documented, so its compatibility and ownership cannot be resolved solely from this PR's Matrix behavior.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Earlier loopback MatrixClient traces exercise the design, but current head c2fc8fa adds CLI reasoning-closure boundaries and lacks an exact-head trace spanning reasoning, tool output, a second reasoning window, and final output. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The optional callback becomes a supported public Plugin SDK contract without recorded owner acceptance, creating a compatibility commitment for external plugins.
  • Resolve merge risk (P1) - The supplied loopback transport evidence predates the exact head's CLI reasoning-closure changes, so its claimed reasoning-to-final ordering is not yet demonstrated at merge candidate identity.
  • Resolve merge risk (P1) - The bug-fix diff has an estimated production net increase of 75 lines; the new cross-runtime lifecycle contract may justify it, but acceptance should confirm the public generic seam is necessary.
  • Complete next step (P2) - Obtain explicit Plugin SDK owner acceptance for the callback and provide a redacted final-head MatrixClient transport trace covering reasoning, tool output, a second reasoning window, final output, and empty mention metadata.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +75, Tests +627, Docs +4. Total +706 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 10 175 100 +75
Tests 10 633 6 +627
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 21 812 106 +706

Review metrics

Metric Value Why it matters
Production versus test delta production +175/-100 (net +75); tests/test support +633/-6; docs +4/-0 The substantial test coverage targets visibility modes and lifecycle ordering, while the positive bug-fix production delta should be justified by the accepted shared SDK seam.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #81892
Summary: This pull request is the candidate fix for the Matrix reasoning-delivery issue.

Members:

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

Merge-risk options

Maintainer options:

  1. Confirm the contract and prove the final head (recommended)
    Obtain explicit Plugin SDK owner acceptance and attach a redacted exact-head MatrixClient trace covering reasoning, tool output, another reasoning window, final output, and empty mention metadata.
  2. Redesign the public seam
    Pause the PR if the callback should not become a stable generic Plugin SDK contract, and replace it with an owner-approved design.

Technical review

Best possible solution:

Accept the documented generic SDK callback only if its owning reviewer agrees it is the right permanent seam, then attach a redacted final-head MatrixClient trace proving notice order and mention safety.

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

Yes from source: current main suppresses typed Matrix reasoning before delivery, while this branch introduces the typed notice path; no local live run was performed under the read-only review constraint.

Is this the best way to solve the issue?

Unclear: the Matrix owner implementation is coherent, but the public SDK contract needs owner acceptance and the final commit needs exact-head transport evidence.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1212f991db46.

Labels

Label justifications:

  • P1: The branch targets a visible Matrix channel regression in reasoning delivery and ordering.
  • merge-risk: 🚨 compatibility: A newly documented and re-exported Plugin SDK callback can become an external-plugin contract.
  • merge-risk: 🚨 message-delivery: The PR changes the sequencing and visibility of Matrix reasoning, tool, and final messages without final-head transport proof.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Earlier loopback MatrixClient traces exercise the design, but current head c2fc8fa adds CLI reasoning-closure boundaries and lacks an exact-head trace spanning reasoning, tool output, a second reasoning window, and final output. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Acceptance criteria:

  • [P1] Review the documented Plugin SDK reply-runtime callback contract.
  • [P1] Capture a redacted exact-head loopback MatrixClient transport trace for resolved reasoning modes and ordered notices.

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Josh Avant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Alix-007: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Obtain explicit Plugin SDK owner acceptance for the public callback.
  • Attach a redacted final-head MatrixClient trace proving reasoning-to-tool-to-reasoning-to-final wire order and empty mention metadata.

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 (24 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-28T20:45:22.541Z sha 9a649b33e11ad70fd778e09ece8ac2203965013d :: needs real behavior proof before merge. :: [P1] Contain reasoning-end callback failures | [P1] Close stream reasoning before assistant partial delivery
  • reviewed 2026-08-28T21:04:29.591Z sha ed32724c221604c87dd32b9f9e42fe9da036b0fd :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-28T21:20:32.580Z sha ca902f8888869e3b409ee501cc00ac6fc4304546 :: needs real behavior proof before merge. :: [P1] Close each CLI reasoning window, not only the first
  • reviewed 2026-08-28T21:31:37.092Z sha f1b4f79815eb9c58301fdb9483983cadd41cde57 :: needs real behavior proof before merge. :: [P1] Close reasoning before tool delivery
  • reviewed 2026-08-28T21:50:23.896Z sha 013d2f63f57ee1b32eb072a842680b53fe228b0f :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-31T19:34:58.648Z sha fbc88fef190bdf9cc6cf2587d868f7162fcad818 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T19:43:37.511Z sha fbc88fef190bdf9cc6cf2587d868f7162fcad818 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-01T20:04:23.865Z sha c2fc8fa :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 23, 2026
@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 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 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 23, 2026
@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 24, 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:

@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 24, 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.

@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 24, 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.

@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 24, 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.

@gaoanze888

This comment was marked as spam.

@gaoanze888

This comment was marked as spam.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Aug 31, 2026
@gaoanze888

This comment was marked as spam.

@clawsweeper clawsweeper Bot added 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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 1, 2026
@gaoanze888

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Reasoning not delivered on Matrix channel (/reasoning on has no effect)

2 participants