Skip to content

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

Closed as not planned

Description

@passwa11

Description

Call deepseek api to report the following error
Bad Request: {"error":{"message":"The reasoning_content in the thinking mode must be passed back to the API.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

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. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Apr 24, 2026
  2. github-actions commented on Apr 24, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Steps to reproduce is empty — please describe what you were doing when the error occurred (e.g., which model, what prompt style, whether extended thinking/reasoning mode was enabled)
    • OpenCode version is missing — please provide the version you are running
    • Operating System is missing — please include your OS and terminal info

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


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

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. Small-tailqwq commented on Apr 24, 2026

    @Small-tailqwq

    存在同样的问题,使用deepseek-v4-pro模型时,使用/review触发子线程后,子线程任务结束时主线程报错.
    The same issue exists. When using the deepseek-v4-pro model, after triggering a sub-thread with /review, the main thread reports an error when the sub-thread task ends.

    The `reasoning_content` in the thinking mode must be passed back to the API.
    
    Image 情况如图所示 The situation is shown in the image.

    下面是我的配置文件:
    Below is my configuration file::

    {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://api.deepseek.com/v1",
        "apiKey": "sk-**********************************"
      },
      "models": {
        "deepseek-v4-pro": {
          "name": "DeepSeek V4-Pro",
          "limit": {
            "context": 1048576,
            "output": 262144
          },
          "options": {
            "reasoningEffort": "max",
            "thinking": {
              "type": "enabled"
            }
          }
        },
        "deepseek-v4-flash": {
          "name": "deepseek-v4-flash"
        }
      }
    }
    

    此问题在多次测试过程中必定触发,不清楚是API提供商问题还是opencode处适配问题,用作信息补充。
    This issue consistently occurs across multiple tests. It is unclear whether it is a problem with the API provider or an adaptation issue with opencode. This is provided as supplementary information.


    补充说明(来自deepseek web 专家模式)
    当你开启 thinking: { type: "enabled" } 后,API 返回的响应中会多一个 reasoning_content 字段(模型的思考过程)。为了保持多轮对话中思考的连续性,DeepSeek API 要求在下一轮请求中,必须把上一轮 assistant 消息里的 reasoning_content 原样传回。

    如果在子线程 /review 结束后,主线程拼接历史消息时,丢失或没有正确传递这个 reasoning_content,API 就会报错:

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

    解法1:
    如果 opencode 支持自定义消息处理,需要检查它是否保存并在下次请求时携带了 reasoning_content。格式类似:

    {
      "role": "assistant",
      "content": "模型的最终回复",
      "reasoning_content": "模型的思考过程(上一次API返回的这个字段)"
    }

    由于你提到不确定是 API 提供商还是 opencode 的适配问题,这很可能是 opencode 没有处理 thinking 模型的特殊消息结构。你可以向 opencode 提交 issue,附上你这段反馈,说明需要支持 DeepSeek 的 thinking 模式。

    解法2:关闭 thinking 模式
    如果不需要思维链,可以在配置中去掉 thinking 和 reasoningEffort:

    "deepseek-v4-pro": {
      "name": "DeepSeek V4-Pro",
      "limit": {
        "context": 1048576,
        "output": 262144
      },
      "options": {
        // 删除或注释掉这两项
        // "reasoningEffort": "max",
        // "thinking": { "type": "enabled" }
      }
    }

    其他解决方案:来自#24097 (comment)
    使用anthropic的接口格式来替换openai的接口格式:

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

    此方案需要移除 reasoningEffort 参数,同时配合 budgetTokens 才能够正常使用。此方法只能作为临时解决方案,最终解决需要 opencode 添加对 deepseek 新模型的支持。
    此方法经过测试会引出一个新的故障:

    Bad Request: {"error":{"message":"The `content[].thinking` in the thinking mode must be passed back to the API.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}
    
  4. devcxl commented on Apr 24, 2026

    @devcxl

    存在同样的问题 我现在使用这个配置在会话中必定触发

    "models": {
        "deepseek-v4-pro": {
          "name": "DeepSeek V4-Pro",
          "limit": {
            "context": 1048576,
            "output": 262144
          },
          "options": {
            "reasoningEffort": "max",
            "thinking": {
              "type": "enabled"
            }
          }
        },
        "deepseek-v4-flash": {
          "name": "deepseek-v4-flash"
        }
      }
    
  5. AzureHalcyon commented on Apr 24, 2026

    @AzureHalcyon

    环境:windows11 25H2
    版本:OpenCode Desktop v1.4.6
    修改~/.config/opencode/opencode.json:

      "provider": {
        "deepseek": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "DeepSeek",
          "options": {
            "baseURL": "https://api.deepseek.com",
            "apiKey": "<DeepSeek API Key>"
          },
          "models": {
            "deepseek-v4-pro": {
              "name": "DeepSeek-V4-Pro",
              "limit": {
                "context": 1048576,
                "output": 262144
              },
              "options": {
                "reasoningEffort": "max",
                "thinking": {
                  "type": "enabled"
                }
              }
            }
          }
        }
      }

    问题:选择DeepSeek-V4-Pro进行多轮对话,几乎一定出现The reasoning_content in the thinking mode must be passed back to the API.报错。

  6. zhaojun8514-cmyk commented on Apr 24, 2026

    @zhaojun8514-cmyk

    same issue

  7. github-actions commented on Apr 24, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

  8. valky86 commented on Apr 24, 2026

    @valky86
    Image

    It also occurs in DeepSeek V4 Flash, probably after five or six rounds of conversation.

  9. DKeAlvaro commented on Apr 25, 2026

    @DKeAlvaro

    I get the same issue

  10. ZhaoCake commented on Apr 26, 2026

    @ZhaoCake

    Same issue. And it seemed that an error of provider, I used deepseek v4 pro in Copilot also occured this.

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