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

Closed

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

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    zenRelates to Zen
    on Apr 29, 2026
  2. github-actions commented on Apr 29, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please check if your issue is already covered by one of these, and consider adding any new details (e.g., specific to the zen/go proxy) as a comment on the most relevant existing issue instead.

  3. WhiteGiverMa commented on Apr 29, 2026

    @WhiteGiverMa
    Author

    Duplicate of #24722 and others. Our contribution: confirmed the same bug affects the zen/go proxy endpoint and provided minimal reproduction with exact error message. Adding detailed findings on #24722.

  4. WhiteGiverMa commented on Apr 29, 2026

    @WhiteGiverMa
    Author

    Reopening — this bug is still unresolved. Keeping this open for visibility. Our zen/go proxy repro adds value: minimal curl reproduction with exact error message. Full context also posted on #24722.

  5. rekram1-node commented on Apr 30, 2026

    @rekram1-node
    Contributor

    Well deepseeks own endpoints behave this exact same way so this isnt a bug, we may inject the reasoning_content: "" into streams to prevent errors for consumers tho

  6. WhiteGiverMa commented on May 1, 2026

    @WhiteGiverMa
    Author

    Ok u r right. Maybe hard to find a more elegant solution.

  7. Mingran23 commented on Aug 14, 2026

    @Mingran23

    I can reproduce a very similar issue with OpenCode Go and DeepSeek V4 Flash.

    Environment:

    • Provider: OpenCode Go subscription
    • Model: DeepSeek V4 Flash
    • Thinking: enabled
    • Agent/tool calling: enabled

    Reproduction:

    1. Start an agent session with thinking enabled.
    2. Let the model call a tool.
    3. The tool returns successfully.
    4. The model should continue generating, but the next request fails with HTTP 400.

    This happens every time in my setup (100% reproducible).

    When I disable thinking, the same workflow works normally.

    I subscribed to OpenCode Go today (2026-08-14), so this is a current reproduction on the Go subscription path.

    Unfortunately, the Operit integration I'm using does not expose the upstream 400 response body. The only error surfaced on my side is:
    NotFoundError: User cancelled the requestDevice() chooser.

  8. rekram1-node commented on Aug 14, 2026

    @rekram1-node
    Contributor

    I can reproduce a very similar issue with OpenCode Go and DeepSeek V4 Flash.

    Are u using opencode? If not then it is because your harness has a bug.

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

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions