Skip to content

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

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

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 loop, run_agent.py, prompt builder 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.

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

Labels

comp/agent Core agent loop, run_agent.py, prompt builder P2 Medium — degraded but workaround exists 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