Skip to content

DeepSeek 3.2: Missing reasoning_content #4947

Closed

Description

@gasatrya

Description

Missing `reasoning_content` field in the assistant message at message index 3. For more information, please refer to https://api-docs.deepseek.com/guides/thinking_with_tools

DeepSeek just upgraded the model, and I got an error message when using the Reasoner model.

OpenCode version

1.0.125

Steps to reproduce

  1. Switch to DeepSeek reasoner

Screenshot and/or share link

Image

Operating System

WSL 2

Terminal

Windows Terminal

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 1, 2025
  2. matjanos commented on Dec 1, 2025

    @matjanos
    Contributor

    Context from DeepSeek documentation: https://api-docs.deepseek.com/guides/reasoning_model

  3. xiaofeifeiovo commented on Dec 2, 2025

    @xiaofeifeiovo

    same question on mac

  4. monotykamary commented on Dec 2, 2025

    @monotykamary
    Contributor

    vercel/ai#10778. This is likely an upstream ai-sdk thing and there is some work started to handle this: vercel/ai#10785

  5. monotykamary commented on Dec 2, 2025

    @monotykamary
    Contributor

    In the meantime you can patch this part up to make it work:

    diff --git a/packages/opencode/src/provider/transform.ts b/packages/opencode/src/provider/transform.ts
    index abe269d5d..00c20bc44 100644
    --- a/packages/opencode/src/provider/transform.ts
    +++ b/packages/opencode/src/provider/transform.ts
    @@ -4,6 +4,46 @@ import type { JSONSchema } from "zod/v4/core"
     
     export namespace ProviderTransform {
       function normalizeMessages(msgs: ModelMessage[], providerID: string, modelID: string): ModelMessage[] {
    +    // DeepSeek: Handle reasoning_content for tool call continuations
    +    // - With tool calls: Include reasoning_content in providerOptions so model can continue reasoning
    +    // - Without tool calls: Strip reasoning (new turn doesn't need previous reasoning)
    +    // See: https://api-docs.deepseek.com/guides/thinking_mode
    +    if (providerID === "deepseek" || modelID.toLowerCase().includes("deepseek")) {
    +      return msgs.map((msg) => {
    +        if (msg.role === "assistant" && Array.isArray(msg.content)) {
    +          const reasoningParts = msg.content.filter((part: any) => part.type === "reasoning")
    +          const hasToolCalls = msg.content.some((part: any) => part.type === "tool-call")
    +          const reasoningText = reasoningParts.map((part: any) => part.text).join("")
    +
    +          // Filter out reasoning parts from content
    +          const filteredContent = msg.content.filter((part: any) => part.type !== "reasoning")
    +
    +          // If this message has tool calls and reasoning, include reasoning_content
    +          // so DeepSeek can continue reasoning after tool execution
    +          if (hasToolCalls && reasoningText) {
    +            return {
    +              ...msg,
    +              content: filteredContent,
    +              providerOptions: {
    +                ...msg.providerOptions,
    +                openaiCompatible: {
    +                  ...(msg.providerOptions as any)?.openaiCompatible,
    +                  reasoning_content: reasoningText,
    +                },
    +              },
    +            }
    +          }
    +
    +          // For final answers (no tool calls), just strip reasoning
    +          return {
    +            ...msg,
    +            content: filteredContent,
    +          }
    +        }
    +        return msg
    +      })
    +    }
    +
         if (modelID.includes("claude")) {
           return msgs.map((msg) => {
             if ((msg.role === "assistant" || msg.role === "tool") && Array.isArray(msg.content)) {
    Image
  6. matjanos commented on Dec 2, 2025

    @matjanos
    Contributor

    #4975 - Thanks @monotykamary .

    There is a PR that solves the problem

  7. self-assigned this
    on Dec 2, 2025
  8. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Dec 2, 2025
  9. Tim-Rambo commented on Dec 4, 2025

    @Tim-Rambo

    Very nice, I had the same issue awesome to see it already being solved and pushed.

  10. rekram1-node commented on Dec 4, 2025

    @rekram1-node
    Contributor

    I merged the fix, release is going out now

  11. rekram1-node commented on Dec 4, 2025

    @rekram1-node
    Contributor

    If it is still an issue on 1.0.130 lmk and we can reopen

  12. monotykamary commented on Dec 4, 2025

    @monotykamary
    Contributor
    Image
  13. rekram1-node commented on Dec 4, 2025

    @rekram1-node
    Contributor

    hahaha

  14. 9p15p commented on Jan 27, 2026

    @9p15p

    v1.1.36 still has this bug.

  15. 9p15p commented on Jan 27, 2026

    @9p15p

    this is my opencode.json

    Operating System: ubuntu
    Terminal: zsh

      "provider": {
        "deepseek": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "DeepSeek",
          "options": {
            "baseURL": "https://api.deepseek.com/v1",
            "apiKey": "{env:DEEPSEEK_API_KEY}"
          },
          "models": {
            "deepseek-chat": {
              "name": "DeepSeek V3",
              "limit": {
                "context": 128000,
                "output": 8192
              }
            },
            "deepseek-reasoner": {
              "name": "DeepSeek R1",
              "limit": {
                "context": 128000,
                "output": 65536
              }
            }
          }
        },
    
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 working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions