fix(deepseek): add native thinking/reasoning_effort support#22218
fix(deepseek): add native thinking/reasoning_effort support#22218asdlem wants to merge 2 commits into
Conversation
DeepSeek V4+ uses extra_body.thinking + top-level reasoning_effort (native protocol, same as Kimi/Z.AI), not OpenRouter-style extra_body.reasoning. Previously the generic code path never sent these parameters for the deepseek provider, so /reasoning commands had zero effect. Changes: - Introduce DeepSeekProfile (subclass of ProviderProfile) with build_api_kwargs_extras() that emits the correct parameter shape - Map Hermes effort levels: low/medium/high → reasoning_effort=high, xhigh → reasoning_effort=max - Default (no reasoning config) enables thinking with effort=high - disabled reasoning sends thinking.type=disabled (no effort param) This follows the same pattern as the existing Kimi provider. Fixes: the deepseek provider previously had no reasoning support at all — /reasoning low/medium/high/xhigh were all no-ops.
|
@asdlem — closed my #25000 as duplicate, per @alt-glitch's consolidation guidance. Two pieces from our diff that might be worth adding here: 1. Transport-layer When
This ensures thinking works even if the profile subsystem has an issue. 2. Transport parity tests
Both diffs are visible at https://github.com/NousResearch/hermes-agent/pull/25000/files — feel free to cherry-pick or ignore. Happy to help if you want a separate PR against your branch with just these two additions. |
- run_agent.py: detect api.deepseek.com and forward is_deepseek param (mirrors existing is_kimi pattern) - chat_completions.py: handle is_deepseek in extra_body.thinking (same protocol as Kimi — fallback when profile subsystem fails) - tests: TestDeepSeekParity (transport) + TestDeepSeekProfile (profile) (5 tests, all passing) Refs: NousResearch#22218, closes NousResearch#25000
|
Automated hermes-sweeper review: this DeepSeek reasoning support is already implemented on current main. Evidence:
I also checked the discussion about adding an |
Summary
extra_body.thinking+ top-levelreasoning_effort/reasoninghad zero effectMotivation
DeepSeek uses its own protocol for reasoning (
extra_body.thinking={"type":"enabled"}+reasoning_effort="high"/"max"), NOT OpenRouter-styleextra_body.reasoning. The codebase only emitted the OpenRouter protocol. This meant/reasoning low/medium/high/xhighwere all no-ops for the deepseek provider.Closes #15700, #21577
Changes
DeepSeekProfile(subclass ofProviderProfile) inplugins/model-providers/deepseek/__init__.pybuild_api_kwargs_extras()that emits the correct parameter shape per effort level:/reasoningextra_body.thinkingreasoning_effort{type: enabled}highnone(disabled){type: disabled}low,medium,high{type: enabled}highxhigh{type: enabled}maxTest Plan
build_api_kwargs_extras()for all effort levels confirmed correct parameter shape/reasoning xhighin Feishu with deepseek-v4-pro confirmed thinking mode active (response detail length increased from ~30 to ~185 chars)/reasoning highand/reasoning maxboth confirmed through Feishu handlerNotes for Reviewers
plugins/model-providers/kimi/__init__.py— Z.AI/Kimi uses the same protocolzaiprovider never returns reasoning_content — Hermes sendsextra_body.reasoning(OpenRouter-style) but Z.AI expectsextra_body.thinking={"type":"enabled"}#16533 (Z.AI/GLM missing thinking) is the same root cause and can use the same approach