feat: add DeepSeek V4 model support with thinking/reasoning_content handling#12205
feat: add DeepSeek V4 model support with thinking/reasoning_content handling#12205roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
…andling Add deepseek-v4-flash and deepseek-v4-pro model definitions with preserveReasoning enabled. Update the DeepSeek provider to use the model info preserveReasoning flag instead of hardcoding deepseek-reasoner. Also update the OpenAI compatible provider to recognize V4 model IDs. Closes #12203
lazyupdate
left a comment
There was a problem hiding this comment.
Thanks for this PR! The refactored preserveReasoning flag approach is clean and extensible. A few things I noticed with the V4 model definitions:
Pricing
The current pricing (inputPrice: 0.28, outputPrice: 0.42) looks like it might be from the legacy deepseek-chat pricing. Per the official V4 pricing page:
| Model | Input (cache miss) | Output | Cache Hit |
|---|---|---|---|
deepseek-v4-flash |
$0.14/M | $0.28/M | $0.0028/M |
deepseek-v4-pro |
$0.435/M ($1.74 disc) | $0.87/M ($3.48 disc) | $0.0145/M (disc) |
Might be worth updating inputPrice, outputPrice, cacheWritesPrice, and cacheReadsPrice to match.
Context window
- contextWindow: 128_000,
+ contextWindow: 1_048_576,V4 supports 1M context — could bump this from 128K.
maxTokens
- maxTokens: 8192,
+ maxTokens: 65536,V4 supports up to 384K max output. 64K would be a reasonable lower bound for thinking models — 8K tends to be tight for reasoning chains plus tool call sequences. Thoughts?
Nice work on the preserveReasoning flag refactor btw, makes it easy to add future thinking models 👍
This PR attempts to address Issue #12203.
Problem
When using new DeepSeek V4 model IDs (
deepseek-v4-flash,deepseek-v4-pro) via the DeepSeek provider or OpenAI-compatible mode, the system fails to handle thereasoning_contentfield, resulting in a 400 Bad Request error because thinking mode is not enabled andreasoning_contentis not passed back to the API.Changes
packages/types/src/providers/deepseek.ts- Addeddeepseek-v4-flashanddeepseek-v4-promodel definitions withpreserveReasoning: truesrc/api/providers/deepseek.ts- ChangedisThinkingModelcheck to use the model infopreserveReasoningflag instead of hardcodingdeepseek-reasoner, making it extensible for any future thinking modelssrc/api/providers/openai.ts- Updated the OpenAI-compatible provider to also recognizedeepseek-v4model IDs for R1 format handlingsrc/api/providers/__tests__/deepseek.spec.ts- Added tests for V4 modelpreserveReasoningflags and thinking parameter passingFeedback and guidance are welcome.
Interactively review PR in Roo Code Cloud