Skip to content

[Bug] DeepSeek V4 fails with 'reasoning_content must be passed back' error in multi-turn conversations #24124

Closed

Description

@LieGeee

Bug Description

When using DeepSeek V4 with OpenCode, multi-turn conversations fail with the error:

The reasoning_content in the thinking mode must be passed back to the API

Steps to Reproduce

  1. Configure DeepSeek V4 in opencode.json:
"deepseek": {
  "npm": "@ai-sdk/openai-compatible",
  "name": "DeepSeek",
  "options": {
    "baseURL": "https://api.deepseek.com",
    "apiKey": "sk-xxx"
  },
  "models": {
    "deepseek-reasoner": {
      "name": "DeepSeek-V4",
      "limit": {
        "context": 1048576,
        "output": 262144
      }
    }
  }
}
  1. Start a conversation with DeepSeek V4
  2. Send a second message in the same conversation
  3. Error occurs

Expected Behavior

Multi-turn conversations should work seamlessly, with reasoning_content properly preserved between turns.

Actual Behavior

The conversation fails because @ai-sdk/openai-compatible doesn't preserve reasoning_content from DeepSeek's thinking mode responses.

Environment

  • OpenCode version: Latest
  • DeepSeek model: deepseek-reasoner (V4)
  • SDK: @ai-sdk/openai-compatible

Root Cause

DeepSeek V4 enables thinking mode by default and returns reasoning_content in responses. The OpenAI-compatible SDK doesn't handle this field, causing it to be lost between conversation turns.

Workaround

Switch to Anthropic API format, which natively supports reasoning modes:

"deepseekv4": {
  "npm": "@ai-sdk/anthropic",
  "name": "DeepSeek",
  "options": {
    "baseURL": "https://api.deepseek.com/anthropic",
    "apiKey": "sk-xxx"
  },
  "models": {
    "deepseek-v4-pro": {
      "name": "DeepSeek-V4-Pro",
      "limit": {
        "context": 1048576,
        "output": 262144
      },
      "options": {
        "thinking": {
          "type": "enabled",
          "budgetTokens": 8192
        }
      }
    }
  }
}

This configuration:

  • Uses @ai-sdk/anthropic instead of @ai-sdk/openai-compatible
  • Points to DeepSeek's Anthropic-compatible endpoint
  • Properly preserves reasoning_content across conversation turns
  • Allows explicit thinking mode configuration

Alternative Solutions

Community members have also suggested using transformRequestBody hooks to manually preserve reasoning_content, but the Anthropic API approach is cleaner and officially supported.

References

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:

  3. added 4 commits that reference this issue on Apr 25, 2026
  4. lfaoro commented on Apr 27, 2026

    @lfaoro
      "provider": {
        "deepseek": {
          "models": {
            "deepseek-v4-flash": {
              "interleaved": {
                "field": "reasoning_content"
              }
            },
            "deepseek-v4-pro": {
              "interleaved": {
                "field": "reasoning_content"
              }
            }
          }
        }
      }

    adding this to opencode.json fixes it

  5. added 4 commits that reference this issue on Apr 28, 2026
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)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions