-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Bug]: Reasoning tokens leak to chat channels when models stream interleaved text/thinking blocks #89473
Copy link
Copy link
Open
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.Security boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:securitySecurity boundary, credential, authz, sandbox, or sensitive-data risk.Security boundary, credential, authz, sandbox, or sensitive-data risk.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Type
Fields
Priority
None yet
Summary
Models that stream interleaved
textandthinkingblocks withintool_call_thinking/reasoningtags can leak reasoning tokens to user-facing chat channels (Discord, etc.), even whenreasoningDefaultis set to"off". The built-instripThinkingTagsFromTextsanitizer is not wired into thesanitizeAssistantTextpipeline, so any thinking tags that survive chunk-level parsing pass through as visible text.Steps to reproduce
reasoningDefault: "off"on the agent.reasoningtags) appears inline in the agent's visible response.Expected behavior
All reasoning/thinking content should be stripped before delivery to chat channels, regardless of whether the model is classified as a reasoning model in
openclaw.json.stripThinkingTagsFromTextexists as a utility but is not applied as a safety net in the final sanitization stage.Actual behavior
Reasoning tokens appear verbatim in the chat channel. The chunk-level
thinking_deltaparsing correctly separates explicitthinkingblocks, but interleavedtextblocks within the same reasoning tag sequence pass throughsanitizeAssistantVisibleTextunstripped becausestripThinkingTagsFromTextis never called.Fix
In
src/embedded-agent-utils.ts,sanitizeAssistantTextshould applystripThinkingTagsFromTextas a final safety net:This is a one-line change that ensures any
reasoning-tagged content surviving earlier stream parsing is caught before delivery.Verified working against the compiled output (
dist/embedded-agent-utils-CjcypG6C.jsline 21-22) after manual hotfix.OpenClaw version
2026.5.28 (e932160)
Operating system
macOS 15.3 (arm64)
Install method
npm global
Model
MiniMax M3 (via LiteLLM proxy). Also reproducible with any model that streams interleaved text/thinking blocks within
reasoningtags.Additional context
Setting
"reasoning": trueon the model definition inopenclaw.jsonpartially mitigates this by enabling the chunk-levelthinking_deltaparsing, but does not fully prevent leaks when the model's streaming behavior interleavestextandthinkingblocks within the same tag sequence. The sanitizer should be defense-in-depth regardless of model classification.