Skip to content

DeepSeek V4 Flash: reasoning_content must be passed back to API when using thinking mode #24130

Description

@wenduof

Description

Description

When using the newly released DeepSeek V4 Flash model (deepseek-v4-flash) for file writing operations, the following error occurs:
The reasoning_content in the thinking mode must be passed back to the API.

Background

DeepSeek released V4 preview today (see: https://mp.weixin.qq.com/s/8bxXqS2R8Fx5-1TLDBiEDg), with two models:

  • deepseek-v4-pro
  • deepseek-v4-flash
    The official announcement explicitly states that V4 is optimized for Agent products including Claude Code, OpenCode, CodeBuddy, etc. Both models support thinking mode, configurable via reasoning_effort parameter (high/max).

Root Cause

DeepSeek Thinking Mode API requires:

  • When thinking mode is enabled, assistant messages must contain a reasoning_content field
  • For tool call scenarios, reasoning_content must be passed back to the API in all subsequent requests
  • Reference: https://api-docs.deepseek.com/guides/thinking_mode#tool-calls
    The known solution in OpenCode is to configure interleaved:
"interleaved": {
  "field": "reasoning_content"
}
Issue
1. New model names (deepseek-v4-flash, deepseek-v4-pro) are not pre-configured with interleaved in the default provider settings
2. Users must manually add this configuration for proper functioning
3. Compared to legacy model deepseek-reasoner, V4's default behavior may differ (per official docs: deepseek-chat temporarily points to deepseek-v4-flash non-thinking mode, but this may change over time)
Suggested Fix
1. Update default provider configuration: Pre-configure interleaved for deepseek-v4-pro and deepseek-v4-flash models
2. Or auto-detect: Automatically handle reasoning_content when DeepSeek models with thinking mode are detected
Workaround
Users can manually configure in opencode.json:
{
  "provider": {
    "deepseek": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "DeepSeek",
      "options": {
        "baseURL": "https://api.deepseek.com/v1",
        "apiKey": "{env:DEEPSEEK_API_KEY}"
      },
      "models": {
        "deepseek-v4-flash": {
          "name": "DeepSeek V4 Flash",
          "interleaved": {
            "field": "reasoning_content"
          }
        },
        "deepseek-v4-pro": {
          "name": "DeepSeek V4 Pro",
          "interleaved": {
            "field": "reasoning_content"
          }
        }
      }
    }
  }
}
Notes on interleaved Configuration
Based on prior issues (#6040, #8934), configuring "interleaved": { "field": "reasoning_content" } for DeepSeek models using the official API (@ai-sdk/openai-compatible) has minimal side effects:
- Slightly increased token usage (DeepSeek API ignores reasoning_content from prior turns per #5577, but still bills for them)
- Slightly increased network bandwidth
This is the recommended configuration per DeepSeek's API documentation.
Related Issues
This issue type has been reported multiple times, but is new for V4 models:
- #4947, #5027, #5332, #5577, #6040, #8934, #10788, #17523
OpenCode Version
1.14.22
Operating System
ubuntu 22.04

### Plugins

rtk

### OpenCode version

1.14.22

### Steps to reproduce

_No response_

### Screenshot and/or share link

_No response_

### Operating System

Ubuntu 22.04

### Terminal

_No response_

Activity

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

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions