Skip to content

fix(matrix): skip reasoning-only messages in reply delivery#24668

Merged
steipete merged 2 commits intoopenclaw:mainfrom
justinhuangcode:fix/matrix-reasoning-leak
Feb 24, 2026
Merged

fix(matrix): skip reasoning-only messages in reply delivery#24668
steipete merged 2 commits intoopenclaw:mainfrom
justinhuangcode:fix/matrix-reasoning-leak

Conversation

@justinhuangcode
Copy link
Contributor

@justinhuangcode justinhuangcode commented Feb 23, 2026

Summary

  • When includeReasoning is active (or reasoningLevel falls back to the model default after being deleted rather than set to "off"), the agent emits reasoning blocks as separate reply payloads prefixed with "Reasoning:\n"
  • Matrix has no dedicated reasoning lane (unlike Telegram which splits reasoning into a separate stream), so these internal thinking traces leak into the chat room as regular user-visible messages
  • Filter out pure-reasoning payloads (those starting with "Reasoning:\n" or a <thinking> tag) before delivery so internal reasoning never reaches the Matrix room

Test plan

  • Enable a reasoning-capable model (e.g. Claude Opus) with extended thinking
  • Send messages via Matrix channel
  • Verify reasoning blocks (e.g. "Reasoning: Planning change summary...") no longer appear as separate chat messages
  • Verify normal assistant replies are unaffected

Fixes #24411

🤖 Generated with Claude Code

Greptile Summary

Adds filtering to prevent reasoning-only messages from appearing in Matrix chat rooms. When reasoning is enabled, the agent emits internal thinking traces prefixed with "Reasoning:\n" or wrapped in <thinking> tags. Since Matrix lacks a dedicated reasoning channel (unlike Telegram), these would leak as user-visible messages. The fix detects and skips pure reasoning payloads before delivery while preserving normal assistant replies.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is well-scoped, defensive, and follows established patterns from the Telegram implementation. The filtering logic is conservative (only removes reasoning-only messages), preserves all normal replies, and adds verbose logging for observability. No breaking changes or edge cases identified.
  • No files require special attention

Last reviewed commit: e5dfbdd

When `includeReasoning` is active (or `reasoningLevel` falls back to the
model default), the agent emits reasoning blocks as separate reply
payloads prefixed with "Reasoning:\n".  Matrix has no dedicated reasoning
lane, so these internal thinking traces leak into the chat as regular
user-visible messages.

Filter out pure-reasoning payloads (those starting with "Reasoning:\n" or
a `<thinking>` tag) before delivery so internal reasoning never reaches
the Matrix room.

Fixes openclaw#24411

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that deliverMatrixReplies skips replies whose text starts with
"Reasoning:\n" or opens with <thinking>/<think>/<antthinking> tags, while
still delivering all normal replies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steipete steipete merged commit 0ded77c into openclaw:main Feb 24, 2026
26 checks passed
@justinhuangcode justinhuangcode deleted the fix/matrix-reasoning-leak branch February 24, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Matrix chat session ignores reasoning setting and prints all reasoning messages regardless

2 participants