feat(deepseek): add reasoning_effort and thinking toggle support#24225
Closed
Booklight12 wants to merge 1 commit into
Closed
feat(deepseek): add reasoning_effort and thinking toggle support#24225Booklight12 wants to merge 1 commit into
Booklight12 wants to merge 1 commit into
Conversation
DeepSeek V4 models support two independent thinking controls via the
native API (api.deepseek.com):
- Thinking toggle: {"thinking": {"type": "enabled/disabled"}}
in extra_body
- Effort control: "reasoning_effort": "high"|"max" at top level
(low/medium → high, xhigh → max per DeepSeek API docs)
Previously the deepseek provider profile was a bare ProviderProfile
that emitted neither parameter — the native API path had no way to
toggle thinking or control reasoning intensity. The OpenRouter path
sent a generic extra_body.reasoning block that does not match
DeepSeek's native format.
This adds a DeepSeekProfile subclass implementing
build_api_kwargs_extras() that emits both parameters, following the
same pattern already used by KimiProfile for Kimi / Moonshot.
Tests: 12 new test cases covering all effort mappings (none, minimal,
low, medium, high, xhigh, max, unknown, missing) plus alias lookup
and profile registration.
Ref: https://api-docs.deepseek.com/guides/thinking_mode
Collaborator
Author
|
Thanks for the heads-up. Closing this in favor of #22218 since the approaches overlap. This PR includes 12 test cases covering all effort mappings (none/minimal/low/medium/high/xhigh/max + edge cases) — none of the competing PRs have tests. Happy to contribute those tests to whichever PR the maintainers prefer. |
This was referenced May 13, 2026
Closed
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.
What does this PR do?
Add
reasoning_effort(intensity control) andthinkingtoggle support for the native DeepSeek provider (api.deepseek.com).DeepSeek V4 models (Flash / Pro) expose two independent thinking controls through their OpenAI-compatible API:
{"thinking": {"type": "enabled/disabled"}}inextra_body"reasoning_effort": "high"/"max"at top levelThe server maps
low/medium→highandxhigh→maxfor compatibility with OpenRouter-style effort levels. This PR mirrors that mapping client-side.Previously, the deepseek provider profile was a bare
ProviderProfilethat emitted neither parameter — the native API path had no way to toggle thinking or control reasoning intensity. The OpenRouter path sent a genericextra_body.reasoningblock that does not match DeepSeek's native format.This PR introduces a
DeepSeekProfilesubclass implementingbuild_api_kwargs_extras()that emits both parameters, following the same pattern already used byKimiProfilefor Kimi / Moonshot.Related Issue
Fixes #
Type of Change
Changes Made
plugins/model-providers/deepseek/__init__.py— Replace bareProviderProfilewithDeepSeekProfilesubclass that implementsbuild_api_kwargs_extras(), emittingextra_body.thinking(toggle) and top-levelreasoning_effort(intensity). Effort mapping:low/medium/minimal→high,xhigh→max,high→high,max→max, unknown →high.tests/providers/test_provider_profiles.py— AddTestDeepSeekProfileclass with 12 test cases covering all effort mappings (none,minimal,low,medium,high,xhigh,max, unknown, missing), alias lookup, profile registration, and thinking toggle behavior.How to Test
pytest tests/providers/test_provider_profiles.py -v -n 0— all 53 tests should pass (41 existing + 12 new).provider: deepseekand a DeepSeek V4 model./reasoning noneto disable thinking — the API request should includeextra_body.thinking = {"type": "disabled"}with noreasoning_effort./reasoning xhigh— the API request should includereasoning_effort: "max"andextra_body.thinking = {"type": "enabled"}./reasoningset) sendsthinking: enabled+reasoning_effort: high.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/A (docstring onbuild_api_kwargs_extrasupdated)cli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Ref: https://api-docs.deepseek.com/guides/thinking_mode