Skip to content

The problem with deepseek-reasoner in OpenCode #8934

Closed as not planned
Closed as not planned

Description

@kirinchin156-source

Description

Questions for OpenCode Developers:

  1. "Does OpenCode support the full reasoning_content cycle for DeepSeek thinking mode?"
  2. "Are there plans to implement saving reasoning chains between tool calls?"
  3. "Is there a workaround for using deepseek reasoner with Shell tools?"

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

Activity

  1. github-actions commented on Jan 16, 2026

    @github-actions
    Contributor

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

    Feel free to ignore if your specific case is not addressed by these issues.

  2. Robinblennert commented on Jan 20, 2026

    @Robinblennert

    Have you fixed it yet?
    I used 128k really quick and couldnt save the work. Crazy NO idea how much of tokens was used but I understand there is a bug.

  3. tongsh6 commented on Mar 10, 2026

    @tongsh6

    I can reproduce a very similar issue with a custom subagent using deepseek/deepseek-reasoner in OpenCode.

    Setup

    Custom local subagent:

    ~/.config/opencode/agents/architect.md

    This is not an oh-my-opencode built-in agent. It is a local custom OpenCode subagent.

    Observed error

    When this subagent performs tool-using work, OpenCode fails with:

    Why this seems like an OpenCode compatibility issue

    According to DeepSeek's official docs for thinking mode + tool calls:

    • during the same reasoning/tool-call turn, the client must send the assistant message back with:
      • content
      • reasoning_content
      • tool_calls

    Docs:
    https://api-docs.deepseek.com/guides/thinking_mode#tool-calls

    This suggests OpenCode is likely dropping reasoning_content when replaying assistant/tool history for reasoning models during tool-call continuation.

    Related notes

    • I also found anomalyco/opencode#9397, which looks closely related
    • This does not appear to be caused by the agent prompt itself
    • It seems specific to:
      • reasoning model
      • tool calls
      • assistant history replay

    Helpful distinction

    This may be reproducible specifically with:

    • custom subagent
    • deepseek/deepseek-reasoner
    • tools enabled (bash: true was enough in my case)

    Temporary workaround on my side is to switch this subagent to deepseek/deepseek-chat or a non-DeepSeek reasoning model.

    If useful, I can provide a more minimal repro prompt next.

  4. tongsh6 commented on Mar 10, 2026

    @tongsh6

    Follow-up: my previous comment lost the fenced blocks due to shell quoting. Here is the exact missing content.

    Local subagent config

    ---
    description: Read-only architecture review agent
    mode: subagent
    model: deepseek/deepseek-reasoner
    temperature: 0.1
    steps: 16
    tools:
      write: false
      edit: false
      bash: true
    ---

    Exact error text

    Missing reasoning_content field in the assistant message at message index 32.
    For more information, please refer to https://api-docs.deepseek.com/guides/thinking_mode#tool-calls
    

    This happened while the custom subagent was doing tool-using work.

  5. tongsh6 commented on Mar 10, 2026

    @tongsh6

    Solution:

    Configure the DeepSeek model with:

    {
      "provider": {
        "deepseek": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "DeepSeek",
          "options": {
            "baseURL": "https://api.deepseek.com/v1",
            "apiKey": "{env:DEEPSEEK_API_KEY}"
          },
          "models": {
            "deepseek-reasoner": {
              "name": "DeepSeek Reasoner",
              "interleaved": {
                "field": "reasoning_content"
              }
            }
          }
        }
      }
    }

    The key part is:

    "interleaved": {
      "field": "reasoning_content"
    }

    After adding this and restarting OpenCode, the issue was resolved.

  6. removed
    bugSomething isn't working
    on May 3, 2026
  7. github-actions commented on Jul 6, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions