Repository navigation
fix(llm): gate OpenAI-compatible reasoning output - #89436
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.
Co-authored-by: zz327455573 <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed June 2, 2026, 8:23 AM ET / 12:23 UTC. Summary PR surface: Source +35, Tests +257. Total +292 across 4 files. Reproducibility: yes. A synthetic OpenAI-compatible stream with content containing an unclosed reasoning tag followed by reasoning_content while reasoning is off exercises the leak path; I did not run it because this review is read-only, but the current parser and added regression tests make the path clear. 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:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the two-parser gating approach after maintainer review, ideally with one redacted live affected-provider or gateway proof showing disabled mirrored reasoning is dropped while enabled native thinking still emits. Do we have a high-confidence way to reproduce the issue? Yes. A synthetic OpenAI-compatible stream with content containing an unclosed reasoning tag followed by reasoning_content while reasoning is off exercises the leak path; I did not run it because this review is read-only, but the current parser and added regression tests make the path clear. Is this the best way to solve the issue? Yes, with a proof caveat. The best code shape is to keep mirrored reasoning fields as strict partition signals and gate only emitted thinking output across both parser paths; the remaining gap is live affected-provider proof, not a different implementation layer. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 6467ddd7edf1. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +35, Tests +257. Total +292 across 4 files. View PR surface stats
Security concerns:
Acceptance criteria:
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
|
|
Land-ready proof for head 0d87f0d:
This replaces #89343 because the contributor fork has maintainer edits disabled; contributor credit is preserved via |
|
Thanks for recreating the fix and preserving the credit. Learned a lot from this process. Glad to see the issue resolved! |
Summary
Verification
Behavior addressed: OpenAI-compatible providers that mirror hidden reasoning no longer leak disabled reasoning into visible output or thinking blocks, while enabled provider-native thinking still emits.
Real environment tested: local OpenClaw targeted unit/agent tests and type/format gates in a normal source checkout.
Exact steps or command run after this patch: node ./node_modules/.bin/oxfmt --check src/llm/providers/openai-completions.ts src/llm/providers/openai-completions.test.ts src/agents/openai-transport-stream.ts src/agents/openai-transport-stream.test.ts && git diff --check; node scripts/run-vitest.mjs src/llm/providers/openai-completions.test.ts src/agents/openai-transport-stream.test.ts; pnpm check:test-types; .agents/skills/autoreview/scripts/autoreview --mode local
Evidence after fix: provider tests passed 17/17; transport tests passed 237/237; test type gate passed; formatter/diff check passed; autoreview reported no accepted/actionable findings.
Observed result after fix: disabled mirrored reasoning is stripped without recovering hidden text, enabled reasoningEffort/OpenRouter/Qwen/Z.ai cases still emit thinking deltas, and transport buffering does not persist disabled thinking deltas after tool calls.
What was not tested: no live external provider call was run for this replacement PR.
Co-authored-by: zz327455573 [email protected]