Skip to content

fix(discord): strip reasoning tags from partial stream preview#24659

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

fix(discord): strip reasoning tags from partial stream preview#24659
steipete merged 2 commits intoopenclaw:mainfrom
justinhuangcode:fix/discord-reasoning-leak

Conversation

@justinhuangcode
Copy link
Contributor

@justinhuangcode justinhuangcode commented Feb 23, 2026

Summary

  • When streamMode is "partial", reasoning/thinking block content leaks into the Discord draft preview because the partial text is forwarded to the draft stream without any filtering
  • Apply stripReasoningTagsFromText before updating the draft and skip pure-reasoning messages (those starting with "Reasoning:\n") so internal thinking traces never reach the user-visible preview
  • This mirrors the approach already used by the Telegram channel (splitTelegramReasoningText in reasoning-lane-coordinator.ts)

Test plan

  • Configure Discord channel with streamMode: "partial" and a model with reasoning enabled
  • Send prompts that trigger multi-step reasoning
  • Verify reasoning blocks no longer appear in the streamed preview messages
  • Verify final reply content is unaffected

Fixes #24532

🤖 Generated with Claude Code

Greptile Summary

Fixes reasoning/thinking tag content leaking into Discord draft stream previews when streamMode is "partial" (or "block"). The updateDraftFromPartial function now calls stripReasoningTagsFromText to remove XML-style thinking tags (<think>, <thinking>, etc.) and skips messages prefixed with "Reasoning:\n" that contain only formatted reasoning content.

  • Applies stripReasoningTagsFromText with { mode: "strict", trim: "both" } to incoming partial text before updating the draft stream
  • Skips empty results and pure-reasoning messages (those starting with "Reasoning:\n")
  • All subsequent logic in updateDraftFromPartial correctly uses the cleaned variable instead of raw text
  • Mirrors the existing approach used by the Telegram channel (splitTelegramReasoningText in reasoning-lane-coordinator.ts)

Confidence Score: 4/5

  • This PR is safe to merge — it adds a well-scoped filter to the Discord draft stream path that mirrors an established pattern from the Telegram channel.
  • The change is narrowly scoped to one function (updateDraftFromPartial) in one file, uses an existing shared utility (stripReasoningTagsFromText), and follows the same pattern already validated in the Telegram channel. All references to partial text within the function correctly use the cleaned variable. The only minor concern is the lack of dedicated unit tests for this specific filtering behavior, but the existing test coverage for stripReasoningTagsFromText and the Telegram reasoning coordinator provide indirect validation.
  • No files require special attention

Last reviewed commit: 93403bf

When streamMode is "partial", reasoning/thinking block content can leak
into the Discord draft preview because the partial text is forwarded to
the draft stream without filtering.  Apply `stripReasoningTagsFromText`
before updating the draft and skip pure-reasoning messages (those
starting with "Reasoning:\n") so internal thinking traces never reach
the user-visible preview.

Fixes openclaw#24532

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@justinhuangcode justinhuangcode force-pushed the fix/discord-reasoning-leak branch from 93403bf to e00d097 Compare February 23, 2026 17:51
…ream

Verify that partial stream updates containing <thinking> tags are stripped
before reaching the draft preview, and that pure "Reasoning:\n" partials
are suppressed entirely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@steipete steipete merged commit 6ea1607 into openclaw:main Feb 24, 2026
26 checks passed
@justinhuangcode justinhuangcode deleted the fix/discord-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: discord Channel integration: discord size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Discord - Reasoning Block Still Appears After Final Message on streamMode "partial"

2 participants