Skip to content

feat(deepseek): plumb V4 thinking + reasoning_effort via provider profile#24130

Closed
zkl2333 wants to merge 1 commit into
NousResearch:mainfrom
zkl2333:feat/deepseek-profile-thinking
Closed

feat(deepseek): plumb V4 thinking + reasoning_effort via provider profile#24130
zkl2333 wants to merge 1 commit into
NousResearch:mainfrom
zkl2333:feat/deepseek-profile-thinking

Conversation

@zkl2333

@zkl2333 zkl2333 commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

The DeepSeek provider profile registered in plugins/model-providers/deepseek/__init__.py was a bare-bones ProviderProfile — no build_api_kwargs_extras override — so on the post-refactor profile path reasoning_effort is silently dropped before the request leaves Hermes, and there's no way to explicitly toggle V4 thinking mode from config. Kimi's profile already implements this pattern; this PR adds the symmetric override for DeepSeek.

Official V4 contract

DeepSeek V4 exposes thinking mode as an explicit API contract (https://api-docs.deepseek.com/guides/thinking_mode):

Signal Location Values Default
Thinking toggle extra_body.thinking {"type": "enabled"} / {"type": "disabled"} enabled
Effort level top-level reasoning_effort "high" / "max" "high" (auto "max" for complex agents)

Hermes → DeepSeek effort mapping

DeepSeek accepts only two effort values, so the wider Hermes vocabulary compatibility-maps:

Hermes reasoning_effort → DeepSeek reasoning_effort
low high
medium high
high high
xhigh max
max max
(thinking disabled) omitted

Changes

  • plugins/model-providers/deepseek/__init__.py — subclass ProviderProfile as DeepSeekProfile, override build_api_kwargs_extras (mirrors KimiProfile); refresh fallback_models to the first-class V4 ids with legacy aliases retained for the deprecation window
  • tests/providers/test_provider_profiles.py — new TestDeepSeekProfile covering registration, V4 fallback models, default-enabled thinking, explicit disable, full effort mapping (low/medium/high/xhigh/max/case/whitespace/unknown/empty)

Note for reviewers

This supersedes #14958 (closed), which added is_deepseek as a transport-level boolean flag — pre-dating the provider_profile migration. The contract emitted by both PRs is identical and was verified live against api.deepseek.com (request returns HTTP 200 with reasoning_content populated when thinking is enabled, empty when disabled). This rewrite simply lands the fix on the architecture main is using now.

Test plan

  • pytest tests/providers/test_provider_profiles.py::TestDeepSeekProfile tests/providers/test_provider_profiles.py::TestKimiProfile — 21 passed (13 new + 8 Kimi regression)
  • Live contract verified in feat(deepseek): plumb reasoning_effort and thinking toggle to V4 API #14958: extra_body.thinking.type=enabled + top-level reasoning_effort=max produces a 200 response with populated reasoning_content; thinking.type=disabled produces a 200 with empty reasoning_content

…file

The DeepSeek provider profile registered in
plugins/model-providers/deepseek/__init__.py was a bare-bones
ProviderProfile — no build_api_kwargs_extras override — so on the
post-refactor profile path reasoning_effort was silently dropped before
the request left Hermes, and there was no way to explicitly toggle V4
thinking mode from config.

Subclass ProviderProfile as DeepSeekProfile and override
build_api_kwargs_extras to emit the V4 contract:

- extra_body.thinking = {"type": "enabled" | "disabled"} (default enabled)
- top-level reasoning_effort = "high" | "max"
  (low/medium/high → "high", xhigh/max → "max" — DeepSeek's documented
  compatibility mapping for the wider OpenAI-style vocabulary)
- omit reasoning_effort entirely when thinking is disabled
  (mirrors KimiProfile)

Also refresh fallback_models from the legacy deepseek-chat/reasoner
aliases to the first-class V4 ids, with the legacy names retained for
the deprecation window.

Reference: https://api-docs.deepseek.com/guides/thinking_mode
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins provider/deepseek DeepSeek API labels May 12, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #22218 (and competing with #16448, #21052). All implement the same pattern: DeepSeekProfile subclass with build_api_kwargs_extras() emitting extra_body.thinking + reasoning_effort mapping. Please consolidate into the earliest open PR.

@zkl2333

zkl2333 commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

Acknowledged — closing as a duplicate of #22218 (earliest open profile-architecture PR with the same DeepSeekProfile + build_api_kwargs_extras shape). I missed it in my PR-graph survey before opening this one. Apologies for the noise.

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

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have provider/deepseek DeepSeek API type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants