Skip to content

reasoning_content dropped in multi-turn tool calls with DeepSeek v4 (causes HTTP 400) #17400

@Wt00000111

Description

@Wt00000111

Bug Description

When using DeepSeek v4 series models (deepseek-v4-pro) with thinking mode enabled, multi-turn conversations with tool calls intermittently fail with HTTP 400: The reasoning_content in the thinking mode must be passed back to the API.

Root Cause

In multi-turn tool-calling scenarios, Hermes sometimes fails to include reasoning_content in assistant messages when constructing subsequent requests.

Evidence from request dumps:

  1. Direct hit (Session 20260429_175349_88d049, Apr 29 18:14):

    • Message [40]: assistant + tool_calls + reasoning_content ✓
    • Message [42]: assistant + tool_calls + reasoning_content ✓
    • Message [44]: assistant + tool_calls WITHOUT reasoning_content ✗ ← causes 400
  2. Null reasoning_content (Session 20260428_160911_013162, Apr 28 16:09):

    • Message [133]: assistant with reasoning_content: null

The pattern: all other models (qwen3.6-plus, kimi-k2.6, etc.) work fine because they don't enforce reasoning_content echo-back. Only DeepSeek enforces this requirement in thinking mode.

Steps to Reproduce

  1. Configure Hermes with deepseek-v4-pro via an OpenAI-compatible endpoint (e.g., OpenCode Go API at opencode.ai/zen/go/v1)
  2. Enable thinking mode (the model defaults to xhigh)
  3. Have a multi-turn conversation with multiple tool calls (5+ rounds of tool usage)
  4. Eventually the 400 error appears when Hermes sends a request missing reasoning_content in an assistant message

Expected Behavior

All assistant messages (especially those with tool_calls) that the API returned with reasoning_content should have that field preserved when echoed back in subsequent requests.

Actual Behavior

Some assistant messages lose their reasoning_content field. The API then rejects the request with:

Error code: 400 - {'error': {'message': 'Error from provider (DeepSeek): The reasoning_content in the thinking mode must be passed back to the API.'}}

Configuration

model:
  default: deepseek-v4-pro
  provider: go-custom
  base_url: https://opencode.ai/zen/go/v1
compression:
  enabled: true
  threshold: 0.5
  target_ratio: 0.2
  protect_last_n: 20

Related

Logs

2026-04-29 18:03:42,992 ERROR root: Non-retryable client error: Error code: 400 - {'error': {'message': 'Error from provider (DeepSeek): The reasoning_content in the thinking mode must be passed back to the API.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}
2026-04-29 18:14:10,896 ERROR root: Non-retryable client error: Error code: 400 - {'error': {'message': 'Error from provider (DeepSeek): The reasoning_content in the thinking mode must be passed back to the API.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_request_error'}}

Full request dumps available at ~/.hermes/sessions/request_dump_*_deepseek*.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/agentCore agent loop, run_agent.py, prompt builderprovider/deepseekDeepSeek APItype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions