Skip to content

feat(agent): pass reasoning_effort + thinking to DeepSeek API - #16448

Closed
zhanglpg wants to merge 2 commits into
NousResearch:mainfrom
zhanglpg:feat/deepseek-reasoning-effort
Closed

feat(agent): pass reasoning_effort + thinking to DeepSeek API#16448
zhanglpg wants to merge 2 commits into
NousResearch:mainfrom
zhanglpg:feat/deepseek-reasoning-effort

Conversation

@zhanglpg

@zhanglpg zhanglpg commented Apr 27, 2026

Copy link
Copy Markdown

Problem

DeepSeek V4 Pro/Flash thinking mode requires two parameters to control thinking effort:

  1. *$reasoning_effort — top-level API parameter (high / max)
  2. $thinking${"type": "enabled/disabled"} in extra_body

Per DeepSeek API docs:

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    reasoning_effort="max",
    extra_body={"thinking": {"type": "enabled"}}
)

Previously, Hermes only passed these parameters for Kimi (api.kimi.com / moonshot.ai). When using DeepSeek via a custom provider or the deepseek provider name, no reasoning parameters were sent — the API relied on DeepSeek's own defaults (thinking=enabled, effort=high). Users had no way to control the effort level.

Changes

3 files, +34 −2

File Change
run_agent.py Detect _is_deepseek (provider name deepseek or api.deepseek.com base URL) and pass to transport
agent/transports/chat_completions.py Handle DeepSeek like Kimi: pass reasoning_effort top-level + thinking in extra_body
hermes_constants.py Add max to VALID_REASONING_EFFORTS (DeepSeek accepts it natively)

How It Works

  • User sets reasoning_effort: max in config.yaml
  • Hermes detects DeepSeek provider (name deepseek or api.deepseek.com base URL)
  • Sends reasoning_effort="max" + extra_body={"thinking": {"type": "enabled"}}
  • DeepSeek uses max thinking effort for the response

Testing

  • All 41 existing test_chat_completions.py tests pass
  • 177/178 reasoning-related tests pass (1 pre-existing failure in test_deepseek_reasoning_content_echo.py, not caused by this change)

Tested on

  • macOS 14 (Intel, x86_64)

@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/deepseek DeepSeek API labels Apr 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #14958, #15577, #15446 — multiple competing PRs for DeepSeek V4 thinking mode support. This is the most minimal approach.

DeepSeek V4 Pro/Flash thinking mode requires both:
- reasoning_effort as a top-level API parameter
- thinking: {type: enabled/disabled} in extra_body

Previously, Hermes only passed these for Kimi providers. DeepSeek
direct API usage was relying on DeepSeek's own defaults (enabled,
effort=high) with no way to control effort level.

Changes:
- run_agent.py: detect _is_deepseek (provider name or api.deepseek.com host)
- chat_completions.py: pass reasoning_effort + thinking extra_body for DeepSeek
- hermes_constants.py: add 'max' to VALID_REASONING_EFFORTS (DeepSeek native)
@zhanglpg
zhanglpg force-pushed the feat/deepseek-reasoning-effort branch from b31b2aa to b00fd49 Compare May 1, 2026 03:06
@zhanglpg zhanglpg changed the title feat: pass reasoning_effort + thinking to DeepSeek API feat(agent): pass reasoning_effort + thinking to DeepSeek API May 1, 2026
@zhanglpg

zhanglpg commented May 1, 2026

Copy link
Copy Markdown
Author

@alt-glitch New to this repo, mind letting me know if this can be approved, or you would prefer a competing PR to be chosen. Let me know.

@teknium1

Copy link
Copy Markdown
Contributor

Automated hermes-sweeper review: this DeepSeek thinking-mode support is already implemented on current main.

  • plugins/model-providers/deepseek/__init__.py:47 defines DeepSeekProfile; its build_api_kwargs_extras() emits extra_body.thinking at line 67 and the top-level reasoning_effort at lines 75-80.
  • agent/transports/chat_completions.py:562-594 invokes that profile hook and merges both outputs into the outgoing Chat Completions request.
  • tests/plugins/model_providers/test_deepseek_profile.py:155-169 verifies the complete deepseek-v4-pro request shape, including reasoning_effort and extra_body.thinking.
  • Commit cd9470f41638bd515db096cd934c463205790110 (fix(deepseek): wire thinking-mode via DeepSeekProfile, not legacy fallback) superseded the legacy transport approach and shipped in v2026.5.16.

Thank you for the focused implementation and for participating in the competing-PR discussion.

@teknium1 teknium1 closed this Jul 12, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/deepseek DeepSeek API sweeper:implemented-on-main Sweeper: behavior already present on current main type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants