Skip to content

fix(moonshot): prevent reasoning_content leak when reasoning is disabled - #96753

Closed
krissding wants to merge 1 commit into
openclaw:mainfrom
krissding:fix/issue-96732-Bug-reasoning_content-leaks-in
Closed

krissding wants to merge 1 commit into
openclaw:mainfrom
krissding:fix/issue-96732-Bug-reasoning_content-leaks-in

Conversation

@krissding

Copy link
Copy Markdown
Contributor

Summary

  • When a model like kimi-k2.6 returns reasoning_content in stream deltas even with reasoning disabled, the parser still detected the field and marked strict content partitioning, causing reasoning text to leak into visible chat output
  • Fix: only scan for reasoning fields (reasoning_content, reasoning, reasoning_text) when shouldEmitReasoning is true, so disabled-reasoning models don't trigger content partitioning from unprocessed reasoning deltas

Test plan

  • Verify moonshot/kimi-k2.6 with reasoning OFF no longer shows internal reasoning text in chat output
  • Verify moonshot/kimi-k2.6 with reasoning ON still correctly emits thinking blocks
  • Verify other OpenAI-compatible providers (DeepSeek, llama.cpp) still work correctly

Closes #96732

🤖 Generated with Claude Code

When a model like kimi-k2.6 returns reasoning_content in stream deltas
even with reasoning disabled, the parser still detected the field and
marked strict content partitioning. This caused the reasoning text to
leak into visible output. Only scan for reasoning fields when
shouldEmitReasoning is true.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jun 25, 2026
@clawsweeper

clawsweeper Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

Close: current main and v2026.6.10 already include the safe OpenAI-compatible reasoning fix from the merged replacement PR, while this branch reintroduces the unsafe scan gate and still lacks real Moonshot proof.

Root-cause cluster
Relationship: superseded
Canonical: #89436
Summary: The current PR is superseded by the merged replacement PR that already shipped the safe OpenAI-compatible reasoning-output gate; the linked Moonshot issue remains separate for any current-main raw-stream evidence.

Members:

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

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the shipped #89436 behavior and handle any remaining Moonshot-specific leak on #96732 with raw current-main stream proof.

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

Yes for the PR regression: current tests and parser source show that mirrored reasoning_content must still mark strict partitioning when reasoning output is disabled. I did not execute tests because this was a read-only review.

Is this the best way to solve the issue?

No. The best solution is already on main: keep reasoning-field detection as a sanitization signal and gate only emitted thinking blocks across both OpenAI-compatible parser paths.

Security review:

Security review needs attention: The diff weakens a hidden-reasoning disclosure boundary by skipping strict partitioning when reasoning output is disabled.

  • [medium] Disabled reasoning can recover hidden tag content — src/llm/providers/openai-completions.ts:404
    The added guard prevents mirrored reasoning fields from marking strict mode, so an unclosed reasoning tag can be flushed as visible text instead of being treated as hidden reasoning.
    Confidence: 0.9

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • steipete: Authored and merged the canonical replacement PR that landed the safe OpenAI-compatible reasoning-output gate across both parser paths. (role: replacement fix author and merger; confidence: high; commits: 06434d85a053; files: src/llm/providers/openai-completions.ts, src/agents/openai-transport-stream.ts, src/llm/providers/openai-completions.test.ts)
  • zz327455573: Opened the earlier contributor PR that identified disabled reasoning_content leakage; the merged replacement preserved that contributor credit while correcting the implementation shape. (role: original fix contributor; confidence: medium; commits: d65a96ab46f9, 06434d85a053; files: src/llm/providers/openai-completions.ts)
  • xialonglee: Authored the merged Moonshot reasoning_content replay backfill PR, adjacent to Kimi/Moonshot reasoning_content compatibility. (role: adjacent Moonshot reasoning contributor; confidence: medium; commits: 0063f3076c17; files: src/llm/providers/stream-wrappers/moonshot-thinking.ts, src/agents/embedded-agent-runner-extraparams-moonshot.test.ts, extensions/moonshot/moonshot.live.test.ts)
  • vincentkoc: Authored prior Ollama/Kimi Moonshot payload compatibility work relevant to the broader Kimi reasoning-parameter compatibility area. (role: adjacent Kimi compatibility contributor; confidence: low; commits: 1492ad20a936; files: src/agents/pi-embedded-runner/moonshot-stream-wrappers.ts, src/agents/pi-embedded-runner/extra-params.ts)

Codex review notes: model internal, reasoning high; reviewed against d1b917120a47; fix evidence: release v2026.6.10, commit 06434d85a053.

@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: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 25, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 27, 2026
@clawsweeper

clawsweeper Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: reasoning_content leaks into chat output with moonshot/kimi-k2.6, frontend reasoning status out of sync

1 participant