Skip to content

DeepSeek thinking mode: reasoning_content not passed back for tool call turns, causing 400 errors #24722

@moe5445

Description

@moe5445

Description

When using DeepSeek models (e.g. deepseek-v4-pro, deepseek-v4-flash) with thinking mode enabled, the API requires that reasoning_content from assistant messages that contained tool calls be included in all subsequent requests. If it's omitted, the API returns a 400 error.

From DeepSeek's docs:

▎ "For turns that do perform tool calls, the reasoning_content must be fully passed back to the API in all subsequent requests. If your code does not ▎ correctly pass back reasoning_content, the API will return a 400 error."

Reproduction:

  1. Configure OpenCode to use a DeepSeek model with thinking mode enabled 2. Ask a question that triggers a tool call (e.g. weather lookup, date check, file read)
  2. The first turn works, but subsequent turns fail with a 400 error

Root cause:
When serializing assistant messages into the conversation context, OpenCode likely drops reasoning_content from the message object. For non-tool-call
turns DeepSeek ignores missing reasoning_content, but for tool call turns it's mandatory.
Expected behavior:
reasoning_content must be preserved in assistant messages that contain tool_calls when sending the conversation history to DeepSeek's API.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

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