Repository navigation
fix(llm): prevent reasoning_content leak when reasoning is disabled - #89343
zz327455573 wants to merge 1 commit into
Conversation
Some models (e.g., MiMo V2.5 Pro) return reasoning_content in streaming deltas even when reasoning is explicitly disabled. The generic openai-completions provider was extracting and processing these fields unconditionally, causing internal thinking to leak into the final output. Added a reasoningEnabled guard before iterating through reasoningFields. When reasoning is off, the fields are ignored and stripped from the normal content flow.
|
Codex review: needs real behavior proof before merge. Reviewed June 2, 2026, 6:55 AM ET / 10:55 UTC. Summary PR surface: Source +3. Total +3 across 1 file. Reproducibility: yes. for the PR regression by source inspection: the existing late-mirrored-reasoning test would stop calling Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep mirrored reasoning fields as a sanitization signal, gate only emitted thinking output using the effective request state, cover both legacy and boundary-aware transport parsers, and require redacted real provider or gateway proof before merge. Do we have a high-confidence way to reproduce the issue? Yes for the PR regression by source inspection: the existing late-mirrored-reasoning test would stop calling Is this the best way to solve the issue? No. The patch is a plausible mitigation, but the best fix should keep reasoning-field detection for sanitization, gate only output emission, and cover the boundary-aware transport path used by the gateway. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against eb417bc672e6. Label changesLabel justifications:
Evidence reviewedPR surface: Source +3. Total +3 across 1 file. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
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
|
6764bee to
e78b1b7
Compare
ad298c2 to
d65a96a
Compare
Replaces #89343 because the contributor fork did not allow maintainer edits. Co-authored-by: zz327455573 <[email protected]>
|
Thanks for the report and initial patch. I could not push fixups to this branch because maintainer edits are disabled, so I recreated the fix in #89436, preserved contributor credit, and landed it on The landed fix keeps mirrored reasoning fields as strict sanitization signals, drops disabled hidden reasoning from both legacy and transport OpenAI-compatible streams, and preserves enabled provider-native thinking paths. For future PRs, enabling "Allow edits by maintainers" lets us patch the original branch directly. |
Replaces openclaw#89343 because the contributor fork did not allow maintainer edits. Co-authored-by: zz327455573 <[email protected]>
Replaces openclaw#89343 because the contributor fork did not allow maintainer edits. Co-authored-by: zz327455573 <[email protected]>
Type of Change
[x] Bugfix (non-breaking change which fixes an issue)
Issue / Problem Description
When using reasoning: false with specific models, reasoning_content is still returned in streaming deltas. The previous generic parser bypassed the entire loop, which unintentionally broke the markStrict() security boundaries.
Behavior
Leaked CoT (Chain of Thought) data in chunk deltas despite model.reasoning being explicitly disabled.
Environment
OpenClaw gateway proxy
Upstream models supporting reasoning (e.g., OpenRouter/Qwen3)
Real Behavior Proof
Before Fix (Leaked Data):data: {"id":"chatcmpl-123","object":"chat.completion.chunk","choices":[{"delta":{"reasoning_content":"leaked_internal_thinking_text","content":null}}]}
After Fix (Clean Output):data: {"id":"chatcmpl-124","object":"chat.completion.chunk","choices":[{"delta":{"content":"Standard response without thinking leakage"}}]}
Fix Implementation Details
src/llm/providers/openai-completions.ts: Restored the main loop and markStrict() triggering logic to preserve the security boundary. Added gating logic exclusively inside appendThinkingDelta output.
src/agents/openai-transport-stream.ts: Implemented parallel output gating control on the transport stream layer using model.reasoning ?? true to prevent false positives during unit tests and block reasoning content appropriately.