Skip to content

feat: add DeepSeek V4 model support with thinking/reasoning_content handling#12205

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/deepseek-v4-thinking-mode
Draft

feat: add DeepSeek V4 model support with thinking/reasoning_content handling#12205
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/deepseek-v4-thinking-mode

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 Bot commented Apr 27, 2026

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 the reasoning_content field, resulting in a 400 Bad Request error because thinking mode is not enabled and reasoning_content is not passed back to the API.

Changes

  1. packages/types/src/providers/deepseek.ts - Added deepseek-v4-flash and deepseek-v4-pro model definitions with preserveReasoning: true
  2. src/api/providers/deepseek.ts - Changed isThinkingModel check to use the model info preserveReasoning flag instead of hardcoding deepseek-reasoner, making it extensible for any future thinking models
  3. src/api/providers/openai.ts - Updated the OpenAI-compatible provider to also recognize deepseek-v4 model IDs for R1 format handling
  4. src/api/providers/__tests__/deepseek.spec.ts - Added tests for V4 model preserveReasoning flags and thinking parameter passing

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

…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

This comment was marked as duplicate.

Copy link
Copy Markdown

@lazyupdate lazyupdate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants