Skip to content

Bug: DeepSeek reasoning_content not passed back in multi-turn conversations #24261

@tomtimlt

Description

@tomtimlt

Description

Bug: DeepSeek reasoning_content not passed back in multi-turn conversations

Affected provider: DeepSeek (via OpenRouter or DeepSeek API directly)
Affected models: DeepSeek V4 Pro (and any DeepSeek model with thinking mode enabled)


Description

When using a DeepSeek model with thinking mode enabled, the API requires that reasoning_content blocks returned in assistant messages are passed back as-is in subsequent turns. OpenCode currently does not preserve these blocks when building the conversation history, causing the following error on the second message:

[DeepSeek] The `reasoning_content` in the thinking mode must be passed back to the API.

Steps to Reproduce

  1. Configure OpenCode with DeepSeek V4 Pro via OpenRouter (openrouter/deepseek/deepseek-v4-pro) or DeepSeek API directly
  2. Enable thinking mode (or use a model where it is on by default)
  3. Send a first message — response succeeds
  4. Send a second message in the same session
  5. Error is thrown immediately

Expected Behavior

OpenCode should preserve the reasoning_content block from assistant messages and include it verbatim when building the messages array for subsequent API calls.

Expected assistant message format in history:

{
  "role": "assistant",
  "content": [
    {
      "type": "reasoning_content",
      "reasoning_content": "<content returned by the model>"
    },
    {
      "type": "text",
      "text": "<actual response>"
    }
  ]
}

Actual Behavior

The reasoning_content block is stripped from the assistant message before the next API call, causing DeepSeek to reject the request.

Environment

  • OpenCode version: v1.14.24
  • OS: MacOs
  • Provider: DeepSeek via OpenRouter
  • Model: deepseek/deepseek-v4-pro

References

Workaround

Disable thinking mode for DeepSeek models in OpenCode settings. This avoids the error but reduces model performance.

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