Skip to content

fix(matrix): recognize MiniMax mm: namespaced reasoning tags in monitor replies#94038

Closed
zhangguiping-xydt wants to merge 7 commits into
openclaw:mainfrom
zhangguiping-xydt:followup/pr-93874
Closed

fix(matrix): recognize MiniMax mm: namespaced reasoning tags in monitor replies#94038
zhangguiping-xydt wants to merge 7 commits into
openclaw:mainfrom
zhangguiping-xydt:followup/pr-93874

Conversation

@zhangguiping-xydt

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

Copy link
Copy Markdown
Contributor

Related: #89473

What Problem This Solves

Fixes an issue where Matrix users could see hidden MiniMax reasoning text in monitor replies when a model reply used mm: thinking tags such as <mm:think>, <mm:thinking>, or <mm:thought>.

Without this patch, Matrix could suppress replies that were entirely reasoning, but mixed reasoning-plus-visible replies could still deliver the hidden reasoning block into the room along with the visible answer.

Why This Change Was Made

  • Matrix now strips recognized thinking blocks before the Matrix send boundary, instead of only using them to decide whether a whole reply is reasoning-only.
  • The stripping uses the public shared openclaw/plugin-sdk/text-chunking reasoning-tag sanitizer so literal <mm:think> or <antml:think> examples inside inline/fenced code are preserved without importing core private files from the Matrix package.
  • The follow-up regression covers the waiting-on-author review request for mixed mm:/antml: reasoning blocks in text replies and locks the code-example preservation boundary.

User Impact

Matrix users no longer receive hidden reasoning text when a monitor reply mixes visible answer text with MiniMax or Anthropic-style thinking blocks. Visible reply text still sends normally, and answers that discuss reasoning tags as literal code examples are not corrupted.

Evidence

  • Real Matrix room proof from the earlier synced head remains relevant for the original reasoning-only path: a disposable unencrypted Matrix room on matrix.org received exactly one visible Matrix event while three mm: reasoning-only replies were suppressed at the Matrix monitor delivery boundary.

  • Additional mixed-path delivery-boundary proof on this head used the real deliverMatrixReplies -> sendMessageMatrix -> client.sendMessage Matrix send path with a fake Matrix client capturing final event content. It verified hidden mm: and antml: reasoning blocks were removed before outbound Matrix payloads, while a literal code example was preserved:

    Matrix mixed reasoning delivery proof passed
    {
      "bodies": [
        "Visible answer",
        "Second answer",
        "Literal example: `<mm:think>draft</mm:think>`"
      ],
      "eventCount": 3
    }
    
  • Focused Matrix regression test with the public SDK sanitizer import:

    $ node scripts/test-projects.mjs extensions/matrix/src/matrix/monitor/replies.test.ts
    [test] starting test/vitest/vitest.extension-matrix.config.ts
    The `envFile` option is deprecated, please use `envDir: false` instead.
    
     RUN  v4.1.9 [local path redacted]
    
    
     Test Files  1 passed (1)
          Tests  9 passed (9)
       Start at  22:00:17
       Duration  2.74s (transform 2.57s, setup 1.18s, import 817ms, tests 378ms, environment 0ms)
    
    [test] passed 1 Vitest shard in 15.60s
    
  • Whitespace/conflict-marker check:

    git diff --check origin/main...HEAD
    Validation result: pass, exit_code=0, 143ms
    
  • Changed-file checks passed locally after refreshing dependencies with pnpm install --frozen-lockfile --ignore-scripts to avoid this host's node-llama-cpp postinstall/CMake 3.19 issue:

    $ node scripts/check-changed.mjs -- extensions/matrix/src/matrix/monitor/replies.ts extensions/matrix/src/matrix/monitor/replies.test.ts
    [check:changed] lanes=extensions, extensionTests
    [check:changed] extensions/matrix/src/matrix/monitor/replies.test.ts: extension test
    [check:changed] extensions/matrix/src/matrix/monitor/replies.ts: extension production
    [check:changed] typecheck extensions
    [check:changed] typecheck extension tests
    [check:changed] runtime import cycles
    Import cycle check: 0 runtime value cycle(s).
    
  • What was not rerun: an external Matrix homeserver room proof for the new mixed-block scenario. The previous disposable Matrix credentials and proof harness are not present in this workspace, so the new evidence is a local delivery-boundary run through the real Matrix send code with a fake client capturing the exact outbound event bodies.

@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 17, 2026
@clawsweeper

clawsweeper Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 8, 2026, 4:09 AM ET / 08:09 UTC.

Summary
The PR expands Matrix monitor reply reasoning-tag regexes to recognize mm: and antml: thinking tags and adds a regression test for dropping mm: reasoning-only replies while sending a visible reply.

PR surface: Source +1, Tests +25. Total +26 across 2 files.

Reproducibility: yes. source inspection gives a high-confidence reproduction: a deliverMatrixReplies payload like <mm:think>secret</mm:think>Visible answer falls through the reasoning-only check and sends raw text. I did not run a local test because this review is read-only.

Review metrics: none identified.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦞 diamond lobster
Patch quality: 🧂 unranked krab
Result: blocked by patch quality or review findings.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Strip recognized reasoning blocks before Matrix send and add a mixed mm: regression test.
  • Keep or refresh the live Matrix proof after the send-boundary change.

Risk before merge

  • [P1] Merging as-is could mark the Matrix mm:/antml: tag leak fixed while mixed reasoning-plus-visible replies still deliver hidden reasoning blocks into Matrix rooms.
  • [P1] The live proof demonstrates reasoning-only suppression, but it does not exercise the mixed block path that source inspection shows still reaches sendMessageMatrix.

Maintainer options:

  1. Strip Mixed Reasoning Before Merge (recommended)
    Update Matrix delivery to remove recognized reasoning blocks from mixed visible replies and add regression coverage for that exact path.
  2. Merge Only The Narrow Drop Fix
    Maintainers could intentionally land only reasoning-only suppression, but the mixed leak should remain tracked as unresolved on the canonical issue.
  3. Pause For A Canonical Replacement
    If maintainers prefer a different Matrix PR to carry the broader sanitizer, pause this PR and route the duplicate PRs to that canonical path.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Strip recognized reasoning tags from Matrix reply text before chunking or media caption send, preserve reasoning-only suppression, and add a regression test for `<mm:think>secret</mm:think>Visible answer` delivering only visible text.

Next step before merge

  • [P2] A narrow automated repair can strip recognized reasoning blocks from Matrix outbound text and add mixed-content regression coverage.

Security
Needs attention: No supply-chain changes were found, but the patch still leaves a concrete hidden-reasoning leak path in Matrix delivery.

Review findings

  • [P1] Strip mixed reasoning before Matrix send — extensions/matrix/src/matrix/monitor/replies.ts:8-11
Review details

Best possible solution:

Strip recognized reasoning tags from Matrix outbound text before chunking or media caption delivery, while preserving the existing drop behavior for replies that become empty after stripping.

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

Yes, source inspection gives a high-confidence reproduction: a deliverMatrixReplies payload like <mm:think>secret</mm:think>Visible answer falls through the reasoning-only check and sends raw text. I did not run a local test because this review is read-only.

Is this the best way to solve the issue?

No. Expanding the regex is a necessary narrow step, but the best Matrix fix also strips recognized reasoning blocks from mixed visible replies using the existing SDK helper or equivalent send-boundary sanitizer.

Full review comments:

  • [P1] Strip mixed reasoning before Matrix send — extensions/matrix/src/matrix/monitor/replies.ts:8-11
    This still leaves the previous blocker open. With the expanded regex, a reply like <mm:think>secret</mm:think>Visible answer is recognized as containing reasoning, but shouldSuppressReasoningReplyText only drops the reply when the stripped remainder is empty; otherwise rawText is sent unchanged. Please strip recognized reasoning tags before chunking/sending and add a mixed reasoning+visible regression test.
    Confidence: 0.92

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4ae8d735bf54.

Label changes

Label changes:

  • add merge-risk: 🚨 message-delivery: The patch still allows mixed recognized reasoning blocks to be delivered as Matrix message text.
  • add merge-risk: 🚨 security-boundary: Hidden model reasoning can contain internal context, and this patch does not close the mixed reasoning leak path before merge.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes live Matrix external-room output and the Real behavior proof check succeeded on the current head; it proves the reasoning-only case, not the mixed leak finding.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body includes live Matrix external-room output and the Real behavior proof check succeeded on the current head; it proves the reasoning-only case, not the mixed leak finding.

Label justifications:

  • P1: The PR targets a real user-facing Matrix reasoning leak, and the remaining blocker is still a high-priority channel privacy/message-delivery bug.
  • merge-risk: 🚨 message-delivery: The patch still allows mixed recognized reasoning blocks to be delivered as Matrix message text.
  • merge-risk: 🚨 security-boundary: Hidden model reasoning can contain internal context, and this patch does not close the mixed reasoning leak path before merge.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦞 diamond lobster and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body includes live Matrix external-room output and the Real behavior proof check succeeded on the current head; it proves the reasoning-only case, not the mixed leak finding.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes live Matrix external-room output and the Real behavior proof check succeeded on the current head; it proves the reasoning-only case, not the mixed leak finding.
Evidence reviewed

PR surface:

Source +1, Tests +25. Total +26 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 2 +1
Tests 1 25 0 +25
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 28 2 +26

Security concerns:

  • [medium] Mixed reasoning can still leak to Matrix — extensions/matrix/src/matrix/monitor/replies.ts:8
    The new tag recognition does not strip mixed reasoning blocks before send, so internal reasoning can still be delivered alongside visible text.
    Confidence: 0.9

Acceptance criteria:

  • [P1] pnpm test extensions/matrix/src/matrix/monitor/replies.test.ts.
  • [P1] pnpm check:changed -- extensions/matrix/src/matrix/monitor/replies.ts extensions/matrix/src/matrix/monitor/replies.test.ts.
  • [P1] git diff --check origin/main...HEAD.

What I checked:

Likely related people:

  • justinhuangcode: Introduced Matrix's reasoning-only suppression helper and the original bare thinking-tag guard. (role: introduced behavior; confidence: high; commits: 1298bd4e1bdb; files: extensions/matrix/src/matrix/monitor/replies.ts)
  • vincentkoc: Recently touched the current Matrix replies/test files during the current tree import/release-history path. (role: recent area contributor; confidence: medium; commits: 3dbe98a1f737, e085fa1a3ffd; files: extensions/matrix/src/matrix/monitor/replies.ts, extensions/matrix/src/matrix/monitor/replies.test.ts)
  • steipete: Recent history shows Matrix test-boundary and reply-payload refactor work on this path. (role: adjacent owner; confidence: medium; commits: 605cb60586eb, 62edfdffbdd0; files: extensions/matrix/src/matrix/monitor/replies.ts)
  • gumadeiras: Recent Matrix monitor/runtime seam commits touched the same monitor module family. (role: adjacent owner; confidence: medium; commits: 3ceec929df0f, d077faab1a1f; files: extensions/matrix/src/matrix/monitor/replies.ts, extensions/matrix/src/matrix/monitor/handler.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (3 earlier review cycles)
  • reviewed 2026-06-26T18:33:35.987Z sha 0317d3a :: needs maintainer review before merge. :: none
  • reviewed 2026-07-07T00:56:49.297Z sha 605178e :: needs maintainer review before merge. :: none
  • reviewed 2026-07-08T07:29:24.974Z sha 0d77028 :: needs changes before merge. :: [P1] Strip mixed reasoning before Matrix send

@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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jun 18, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. and removed proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 19, 2026
@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: 🧂 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. labels Jun 20, 2026
@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. 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. labels Jun 20, 2026
…or replies

Mirrors openclaw#93874 (slack monitor) for the matrix extension. The matrix
reply delivery path checks shouldSuppressReasoningReplyText to drop
reasoning-only payloads before they reach the Matrix room; the
THINKING_TAG_RE / THINKING_BLOCK_RE patterns only matched bare,
antml:, or antthinking variants, so MiniMax <mm:think>…</mm:think>
payloads were treated as ordinary replies and the reasoning text was
sent into the Matrix room (a reasoning leak, not just a missed preview).

Align the regexes with src/shared/text/reasoning-tags.ts and openclaw#93767's
precedent by adding an optional (?:antml:|mm:)? prefix on
think/thinking/thought; antthinking is left unprefixed.

Adds a regression test that streams three mm: namespaced reasoning-only
replies and asserts only the visible answer reaches sendMessageMatrix.
@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: 🧂 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. labels Jun 20, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jul 7, 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 7, 2026
@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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 8, 2026
@zhangguiping-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated this PR after syncing with current main:

  • Head is now 0d77028d38, merged from origin/main at 7e0324263b.
  • The PR body was refreshed with live Matrix room proof plus current synced-head validation.
  • Real behavior proof passed on the latest head.
  • Relevant Matrix and quality checks passed: QA Smoke CI (matrix), check-test-types, check-lint, build-artifacts, and Critical Quality (channel-runtime-boundary).
  • The only failing CI job is checks-node-compact-small-whole-2, where src/tui/tui-pty-local.e2e.test.ts > creates and adopts a fresh session through the real Gateway backend timed out after 150s. This PR only changes extensions/matrix/src/matrix/monitor/replies.ts and extensions/matrix/src/matrix/monitor/replies.test.ts, so that failure is outside this Matrix diff.

Could you please refresh the proof/status labels and rerun the unrelated failed shard if needed?

@clawsweeper

clawsweeper Bot commented Jul 8, 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: 🧂 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. 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. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. 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. labels Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix 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. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant