feat(deepseek): support v4 models#71105
Conversation
Greptile SummaryThis PR adds
Confidence Score: 4/5Mostly safe to merge, but the unconditional reasoning_content backfill when thinking is disabled should be addressed to avoid potential API 400 errors in the disabled-thinking path. One P1 logic bug: backfillDeepSeekReasoningPayload runs unconditionally, including when thinkingType is "disabled", which can send reasoning_content to DeepSeek in a context where thinking is turned off. The happy-path (thinking enabled) is well-tested and correct; remaining findings are limited to this one control-flow gap. extensions/deepseek/stream.ts — the payload-patch closure should guard the backfill call on thinkingType not being "disabled". Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/deepseek/stream.ts
Line: 97-111
Comment:
**`reasoning_content` backfilled even when thinking is disabled**
`backfillDeepSeekReasoningPayload` is called unconditionally regardless of `thinkingType`. When thinking is explicitly disabled (`thinkingType === "disabled"`), the code correctly removes `reasoning`, `reasoning_effort`, and `reasoningEffort` from the top-level payload — but still injects `reasoning_content` into individual assistant messages for any context messages that contain thinking blocks. Sending `reasoning_content` in messages alongside `thinking: { type: "disabled" }` conflicts with DeepSeek's API contract and could result in a 400 error on those calls.
```suggestion
if (thinkingType !== "disabled") {
backfillDeepSeekReasoningPayload({
payload,
contextMessages: (context as { messages?: unknown }).messages,
});
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(deepseek): support v4 models" | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a0592b8d3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
77aec4b to
f2026b8
Compare
f2026b8 to
bf7c9bc
Compare
|
Thanks @lsdsjy, landed this via squash as 7d1891e. Maintainer rewrite summary:
Validation:
|
|
I find the same issue with the same models in openclaw v2026.4.25, currently, you can't use /think with deepseek v4 models, specially on flash version after a multistep conversation it fail " run error: LLM request failed: provider rejected the request schema or tool payload." |
Summary
reasoning_contentto be replayed with tool-call history; missing it can make the DeepSeek API reject follow-up requests with 400.reasoning_contentthrough subsequent requests, including later user turns: https://api-docs.deepseek.com/guides/thinking_mode#tool-callsdeepseek-v4-proanddeepseek-v4-flash, defaults onboarding todeepseek/deepseek-v4-flash, enables DeepSeek thinking payloads, and backfillsreasoning_contentinto replayed OpenAI-compatible chat messages.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
reasoning_contentin replay payloads for assistant messages that includetool_calls.content,reasoning_content, andtool_callsfor thinking-mode tool calls.Regression Test Plan (if applicable)
extensions/deepseek/index.test.tsreasoning_contenton every replayed assistant message, including tool-call turns and prior turns.buildOpenAICompletionsParamsconversion without requiring live DeepSeek credentials.User-visible / Behavior Changes
deepseek-v4-proanddeepseek-v4-flashwith 1,048,576 context and 262,144 max output.deepseek/deepseek-v4-flash.thinking: { type: "enabled" }andreasoning_effortby default for reasoning-capable models.reasoning_content; empty reasoning strings are also replayed when present.Diagram (if applicable)
Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation: N/ARepro + Verification
Environment
pnpmdeepseek-v4-pro,deepseek-v4-flashSteps
buildOpenAICompletionsParams.Expected
reasoning_contentalongsidecontentandtool_callswhere applicable.reasoning_contentis preserved as an explicit empty string when the stored thinking block exists.Actual
Evidence
Attach at least one:
Validation runs:
Additional local check:
Known unrelated local gate result:
Human Verification (required)
What you personally verified (not just CI), and how:
deepseek-v4-proanddeepseek-v4-flash; assistant messages withtool_calls; prior-turn replay after a later user message; explicit empty reasoning string.codex review --base origin/mainwas not run in this session.Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes)Yes)No)deepseek/deepseek-v4-flash.Risks and Mitigations
reasoning_contentvalues.