feat(providers): support deepseek native api reasoning_ - #21052
feat(providers): support deepseek native api reasoning_#21052WuTianyi123 wants to merge 1 commit into
Conversation
DeepSeek's native API accepts top-level reasoning_effort (high/max),
not extra_body.reasoning. Previously the DeepSeek profile used the
base ProviderProfile which returned ({}, {}) for build_api_kwargs_extras,
so reasoning_effort config was silently ignored when using the DeepSeek
native provider (api.deepseek.com).
Changes:
- Add 'max' to VALID_REASONING_EFFORTS in hermes_constants.py
- DeepSeekProfile overrides build_api_kwargs_extras to emit
reasoning_effort as top-level param with value mapping:
low/medium/minimal → high, xhigh/max → max
- Summary path in run_agent.py handles deepseek top-level
reasoning_effort (like LM Studio), bypassing extra_body.reasoning
- Update UI help texts and config example comments to include 'max'
Tests: 7 new transport parity tests in TestDeepSeekParity.
All existing tests pass.
teknium1
left a comment
There was a problem hiding this comment.
Thanks for identifying the native DeepSeek reasoning_effort gap. The normal request path is now implemented by merged PR #26648 (cd9470f41638bd515db096cd934c463205790110): plugins/model-providers/deepseek/__init__.py:47-82 emits both top-level reasoning_effort and extra_body.thinking, and agent/transports/chat_completions.py:562-575 applies the profile extras.
Problems
- The remaining iteration-limit summary path still calls
chat.completions.create()directly. It handles only LM Studio atagent/chat_completion_helpers.py:1650-1691, and repeats the same request construction on retry at:1774-1787. - The PR's summary branch adds only
reasoning_effort; it would not include DeepSeek V4'sextra_body.thinkingcontrol that the canonical profile emits atplugins/model-providers/deepseek/__init__.py:67-80.
Suggested changes
- Salvage the summary-path portion into
agent/chat_completion_helpers.py, preferably by deriving the summary extras from the registered provider profile so its wire shape cannot drift from the main transport. - Add DeepSeek V4 initial-summary and retry-summary tests covering enabled and disabled reasoning.
Automated hermes-sweeper review.
| @@ -10444,11 +10470,18 @@ def _handle_max_iterations(self, messages: list, api_call_count: int) -> str: | |||
| (self.provider or "").strip().lower() == "lmstudio" | |||
There was a problem hiding this comment.
This bypasses the generic extra_body.reasoning path for DeepSeek, but the subsequent summary kwargs add only reasoning_effort. DeepSeek V4 also needs its extra_body.thinking control; please source both extras from the DeepSeek provider-profile contract so the direct summary request matches normal transport calls.
What does this PR do?
Fix
reasoning_effortbeing silently ignored when using the DeepSeeknative provider (
api.deepseek.com). Two issues:reasoning_effort(high/max),not
extra_body.reasoning. The baseProviderProfilereturns({}, {})for
build_api_kwargs_extras, so the config was never sent."max"was not inVALID_REASONING_EFFORTS— setting it causedUnknown reasoning_effort 'max', using default (medium).Related Issue
N/A (no existing issue)
Type of Change
Changes Made
hermes_constants.py: Add"max"toVALID_REASONING_EFFORTSplugins/model-providers/deepseek/__init__.py: NewDeepSeekProfileclasswith
build_api_kwargs_extrasemitting top-levelreasoning_effort,mapping:
low/medium/minimal→"high",xhigh/max→"max"run_agent.py: Summary path handles deepseek like LM Studio (top-levelreasoning_effort, notextra_body.reasoning)cli.py:/reasoninghelp text updatedcli-config.yaml.example: Options comment updatedbatch_runner.py: Docstring + valid_efforts list updatedtests/providers/test_transport_parity.py: 7 newTestDeepSeekParitytestsHow to Test
pytest tests/providers/test_transport_parity.py -q(26→33 tests, deepseekmapping coverage)
pytest tests/run_agent/test_run_agent.py -k reasoning -q(35 reasoning tests)pytest tests/providers/ -q(90 provider tests)reasoning_effort: xhighwithprovider: deepseek, verifyreasoning_effort: maxis sent in API requestChecklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
cli-config.yaml.example— config comment updatedScreenshots / Logs
Before (
reasoning_effort: xhighwithprovider: deepseek):_supports_reasoning_extra_body()returnedFalsereasoning_effortwas silently dropped from API requestAfter:
reasoning_effortas top-level paramxhigh→"max",medium→"high"(per DeepSeek API spec)