Skip to content

DeepSeek V4 Pro via zen/go: reasoning_content inconsistency causes "must be passed back to the API" error in multi-turn tool calls #25000

@WhiteGiverMa

Description

@WhiteGiverMa

Description

When using DeepSeek V4 Pro via the opencode.ai/zen/go/v1 endpoint, multi-turn conversations with tool calls fail intermittently with:

Error from provider (DeepSeek): The `reasoning_content` in the thinking mode must be passed back to the API.

Root Cause

DeepSeek V4 Pro's thinking mode is all-or-nothing: once ANY assistant message in the conversation history includes reasoning_content, ALL subsequent assistant messages MUST also include it. If even one message lacks it (e.g., a tool_calls message where reasoning was omitted), the API rejects the entire request.

Reproduction (minimal)

FAILS — first assistant has reasoning_content, second (tool_calls) does NOT:

{
  "model": "deepseek-v4-pro",
  "messages": [
    {"role": "user", "content": "帮我查下文件"},
    {"role": "assistant", "content": "好的,我来帮你查。", "reasoning_content": "用户需要查文件,我应该用工具。"},
    {"role": "user", "content": "读SOUL.md"},
    {"role": "assistant", "content": null, "tool_calls": [{"id":"c1","type":"function","function":{"name":"read","arguments":"{\"path\":\"SOUL.md\"}"}}]},
    {"role": "tool", "tool_call_id": "c1", "content": "SOUL内容"},
    {"role": "user", "content": "写个总结"}
  ],
  "tools": [{"type":"function","function":{"name":"read","description":"read","parameters":{"type":"object","properties":{"path":{"type":"string"}}}}}
],
  "max_tokens": 20
}

→ Returns: "The reasoning_content in the thinking mode must be passed back to the API."

PASSES — ALL assistant messages consistently have reasoning_content:

{
  "model": "deepseek-v4-pro",
  "messages": [
    {"role": "user", "content": "读SOUL.md"},
    {"role": "assistant", "content": null, "tool_calls": [{"id":"c1","type":"function","function":{"name":"read","arguments":"{\"path\":\"SOUL.md\"}"}}], "reasoning_content": "需要读文件,调用read工具。"},
    {"role": "tool", "tool_call_id": "c1", "content": "# SOUL\n我是时崎狂三"},
    {"role": "user", "content": "总结"}
  ],
  "tools": [{"type":"function","function":{"name":"read","description":"read","parameters":{"type":"object","properties":{"path":{"type":"string"}}}}}
],
  "max_tokens": 30
}

→ Works fine (200 OK).

Impact

  • Any multi-turn conversation using DeepSeek V4 Pro with tool calls (e.g., OpenClaw, Claude Code, Cursor, etc.) will fail after the first tool call
  • The zen/go proxy appears to sometimes omit reasoning_content from tool_calls responses, creating the inconsistency
  • This is the typical pattern for coding agents where model generates text → calls tools → continues conversation

Suggested Fix

The zen/go proxy should either:

  1. Ensure reasoning_content is consistently included in ALL assistant messages when thinking mode is active, including tool call messages, OR
  2. Strip reasoning_content from ALL messages in the history before forwarding to DeepSeek if consistency cannot be guaranteed

Environment

  • Endpoint: https://opencode.ai/zen/go/v1/chat/completions
  • Model: deepseek-v4-pro
  • Timestamp: 2026-04-30 03:30 UTC

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)zenRelates to Zen

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