fix(deepseek): strip reasoning_content when extra_body disables thinking#74403
fix(deepseek): strip reasoning_content when extra_body disables thinking#74403SymbolStar wants to merge 1 commit into
Conversation
When extra_body sets thinking.type to 'disabled', the extra_body wrapper runs after the DeepSeek provider wrapper which may have already backfilled reasoning_content on assistant messages. The stale reasoning_content then causes DeepSeek to reject the payload with 400. Strip reasoning_content from all messages after extra_body is applied whenever the final payload has thinking.type === 'disabled'. Fixes openclaw#74374
Greptile SummaryThis PR fixes a DeepSeek 400 error that occurs when Confidence Score: 5/5Safe to merge — the fix is minimal, narrowly scoped to the disabled-thinking path, and consistent with how other payload patches are applied in this codebase. No correctness issues found. The guard conditions are thorough (type-checks No files require special attention. Reviews (1): Last reviewed commit: "fix(deepseek): strip reasoning_content w..." | Re-trigger Greptile |
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: the patch targets a real DeepSeek disabled-thinking bug and current main still lacks post- Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence path: current main can enable/backfill DeepSeek Is this the best way to solve the issue? Unclear as submitted. The cleanup direction matches the DeepSeek failure, but maintainers should decide whether this belongs in the generic Security review: Security review cleared: The diff only changes TypeScript runtime payload cleanup and a regression test; it does not touch workflows, dependencies, lockfiles, secrets, publishing, downloads, or generated/vendor code. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against b9933b2ec119. |
|
Codex review: needs maintainer review before merge. What this changes: This PR adds post- Maintainer follow-up before merge: This is already an open implementation PR for a narrow regression; the next action is maintainer review of the generic cleanup scope and targeted validation, not a separate ClawSweeper repair PR. Review detailsBest possible solution: Land a narrow, tested fix that makes DeepSeek V4 disabled-thinking payloads consistent whether disabled thinking comes from OpenClaw's thinking level or from Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 8cf724a381a3. |
|
Hi @steipete — friendly ping 🙏 CI is green now (rebased on latest main). Would appreciate a look when you get a chance! |
|
This pull request has been automatically marked as stale due to inactivity. |
|
Closing per author cleanup — this PR has been waiting on review for 14+ days. Happy to reopen if a maintainer wants to pick it up; otherwise the fix can be re-proposed if the underlying issue resurfaces. |
Root Cause
The
extra_bodywrapper (createOpenAICompletionsExtraBodyWrapper) runs after the DeepSeek V4 provider wrapper. WhenthinkingLevelis not explicitlyoff/none(e.g. user setsparams.thinking: falsewhich isn't recognized as a string level), the provider wrapper backfillsreasoning_content: ""on assistant messages and setsthinking: { type: "enabled" }. Thenextra_bodyoverwritesthinkingto{ type: "disabled" }, leaving stalereasoning_contenton messages — causing DeepSeek to reject with 400.Fix
After applying
extra_bodyto the payload, check if the resultingthinking.type === "disabled". If so, stripreasoning_contentfrom all messages in the payload. This ensures no provider-wrapper backfill or model-response remnant leaks into a disabled-thinking request.Changed Files
src/agents/pi-embedded-runner/extra-params.ts— strip logic afterObject.assign(payloadObj, extraBody)src/agents/pi-embedded-runner-extraparams.test.ts— regression testFixes #74374