Skip to content

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

Closed

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

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

    @github-actions
    Contributor

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

    There appear to be several issues open today covering the same DeepSeek V4 reasoning_content / interleaved configuration problem. Please coordinate with the reporters of those issues, and consider closing as a duplicate if the underlying problem is the same.

  3. fkyah3 commented on Apr 25, 2026

    @fkyah3

    Same issue affecting multiple projects — updated list as of April 26:

    Project Issue
    OpenCode #24104 #24130 #24261
    OpenClaw openclaw#71160 openclaw#71455
    n8n n8n#29119
    Continue.dev continuedev#10758
    HuggingFace Chat-UI chat-ui#1664

    All share the same root cause: AI SDKs don't preserve reasoning_content on assistant messages with tool_calls across multi-turn agent conversations. Our fork (fkyah3/opencode-fkyah3) implements a brute-force fix at the normalizeMessages() level: unconditionally inject reasoning_content: "" for ALL assistant messages before API dispatch. Verified working with direct DeepSeek API.

    See #24261 for more context. Not a config issue — just ecosystem adaptation lag.

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