Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 24, 2025

Summary

This PR fixes the issue where DeepSeek V3.1's reasoning/thinking section doesn't appear when reasoning effort is enabled through the OpenAI Compatible provider.

Problem

When using DeepSeek V3.1 with the OpenAI Compatible provider and enabling reasoning effort, the thinking/reasoning section was not visible in the UI, even though the model supports reasoning.

Solution

Updated the OpenAI provider to properly detect DeepSeek V3/chat models when reasoning is enabled. The fix checks if:

  • The model ID contains "deepseek" (case-insensitive) AND
  • Reasoning is enabled (via reasoning effort configuration)

When both conditions are met, the model is treated as a reasoning model and uses the R1 format, which properly displays the reasoning content.

Changes

  • Modified src/api/providers/openai.ts to detect DeepSeek models with reasoning enabled
  • Added comprehensive test coverage for DeepSeek V3 reasoning scenarios
  • Tests verify that R1 format is used and reasoning_effort is passed correctly

Testing

  • ✅ All existing tests pass
  • ✅ Added new tests for DeepSeek V3 and DeepSeek-chat models with reasoning
  • ✅ Linting and type checking pass

Related Issues

Fixes #7370

Notes

This fix may also address similar issues with other models like GLM-4.5 mentioned in the issue comments, though specific testing for GLM-4.5 would be needed to confirm.

Feedback

This PR attempts to address Issue #7370. Feedback and guidance are welcome!


Important

Fixes DeepSeek V3 models to display reasoning content when reasoning effort is enabled by updating detection logic and using R1 format.

  • Behavior:
    • Fixes issue where DeepSeek V3 models did not display reasoning content when reasoning effort is enabled.
    • Updates OpenAiHandler in openai.ts to detect DeepSeek models with reasoning enabled and use R1 format.
  • Testing:
    • Adds tests in openai.spec.ts to verify DeepSeek V3 and DeepSeek-chat models use R1 format and pass reasoning_effort correctly.
    • Ensures all existing tests pass and new tests cover the updated behavior.
  • Misc:

This description was created by Ellipsis for 92c1e3b. You can customize this summary. It will automatically update as commits are pushed.

…ffort

- Updated OpenAI provider to detect DeepSeek V3/chat models when reasoning is enabled
- DeepSeek V3.1 models now properly show reasoning/thinking sections
- Added test coverage for DeepSeek V3 reasoning scenarios

Fixes #7370
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 24, 2025 14:25
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Aug 24, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.

(modelId.toLowerCase().includes("deepseek") && reasoning) ||
modelId.includes("deepseek-reasoner") ||
enabledR1Format
const deepseekReasoner = isDeepSeekWithReasoning
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The variable naming here could be clearer. We have isDeepSeekWithReasoning and deepseekReasoner which seem redundant. Could we simplify to use just one consistent variable name?

const deepseekReasoner = modelId.includes("deepseek-reasoner") || enabledR1Format
// Check if this is a DeepSeek model with reasoning enabled
const isDeepSeekWithReasoning =
(modelId.toLowerCase().includes("deepseek") && reasoning) ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this intentional to keep the detection logic inline? Consider extracting modelId.toLowerCase().includes("deepseek") && reasoning into a helper method like isDeepSeekModelWithReasoning() for better readability and potential reuse.

expect(callArgs.temperature).toBe(0.6)
})

it("should detect DeepSeek V3 models with reasoning effort as reasoning models", async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests look good, but what about edge cases like "DeepSeek-V3" (uppercase) or "deepseek-v3.1"? Should we add tests to ensure the case-insensitive matching works correctly for all variations?

// which combines system and user messages
expect(callArgs.messages[0].role).toBe("user")
expect(callArgs.messages[0].content).toContain("You are a helpful assistant.")
expect(callArgs.reasoning_effort).toBe("medium")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could we also verify that there's no separate system message in the converted messages? This would make the R1 format usage more explicit:

const deepseekReasoner = modelId.includes("deepseek-reasoner") || enabledR1Format
// Check if this is a DeepSeek model with reasoning enabled
const isDeepSeekWithReasoning =
(modelId.toLowerCase().includes("deepseek") && reasoning) ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue comment mentions GLM-4.5 has the same problem. Should we consider adding similar detection for GLM models in this PR, or would that be better as a separate fix to keep this PR focused?

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 24, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Aug 26, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Aug 26, 2025
@daniel-lxs
Copy link
Member

Issue needs scoping

@daniel-lxs daniel-lxs closed this Aug 27, 2025
@github-project-automation github-project-automation bot moved this from PR [Needs Prelim Review] to Done in Roo Code Roadmap Aug 27, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Needs Preliminary Review size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

DeepSeek V3.1 reasoning section does not appear

4 participants