fix(openai): DeepSeek V4 thinking mode compatibility (builds on #12181)#12204
Open
abcxlab wants to merge 7 commits intoRooCodeInc:mainfrom
Open
fix(openai): DeepSeek V4 thinking mode compatibility (builds on #12181)#12204abcxlab wants to merge 7 commits intoRooCodeInc:mainfrom
abcxlab wants to merge 7 commits intoRooCodeInc:mainfrom
Conversation
added 3 commits
April 27, 2026 10:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Builds on: #12181 (OpenAI Compatible DeepSeek R1 Support)
Closes: #12173
Closes: #12177
Closes: #12174
Roo Code Task Context (Optional)
Description
This PR provides an incremental fix for DeepSeek V4 compatibility when using the "OpenAI Compatible" provider, building upon the foundations laid in #12181. It specifically addresses the
400 OpenAI completion error: 400 The reasoning_content in the thinking mode must be passed back to the APIerror that occurs during tool-calling sequences.Key Implementation Details:
mergeToolResultText: truefor R1/DeepSeek models inOpenAiHandler. This ensuresenvironment_detailsare merged into the preceding tool message instead of being sent as a separateusermessage, which prevents breaking the V4 reasoning chain.extra_body.thinking: { type: "enabled" }into the API request as required by the official DeepSeek V4 documentation for OpenAI SDK usage.reasoning_effortmapping (e.g., mappingxhightomaxfor DeepSeek).temperatureandtop_pwhen thinking mode is active.preserveReasoning: trueto model capabilities and enhancedTask.buildCleanConversationHistoryto recognize and retainreasoning_contentin the conversation history, preventing it from being stripped during context cleaning.Test Procedure
src/api/providers/__tests__/openai.spec.ts("DeepSeek V4 / R1 Compatibility"). These tests verify correct parameter injection, strength mapping, and that standard models (like GPT-4o) remain unaffected.Pre-Submission Checklist
Screenshots / Videos
N/A (Backend logic and protocol fix).
Documentation Updates
Additional Notes
Get in Touch
Interactively review PR in Roo Code Cloud