Skip to content

[BUG] DeepSeek reasoning_content not preserved across tool calls, causing HTTP 400 error #28945

Closed

Description

@Loss-of-time

Description

问题描述

当使用 DeepSeek reasoning/thinking 模式时,工具调用(如 LSP)后会导致 HTTP 400 错误:

Error from provider (DeepSeek): The reasoning_content in the thinking mode must be passed back to the API.

复现步骤

  1. 配置 opencode 使用 DeepSeek provider(如 deepseek/deepseek-reasoner 或其他 reasoning 模型)
  2. 在任何项目中运行需要工具调用的操作(例如:@main.go 的 LSP 分析)
  3. opencode 调用 LSP 工具获取结果后,将结果发送给 DeepSeek API 进行下一轮处理
  4. DeepSeek API 返回 400 错误,因为 reasoning_content 没有从上一轮响应传回

错误日志

RequestExecutor.execute: Provider request failed with HTTP 400:
{"error":{"message":"Error from provider (DeepSeek): The reasoning_content in the thinking mode must be passed back to the API.",
"type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

根因分析

DeepSeek 的 reasoning/thinking 模式会在 API 响应中返回 reasoning_content 字段。根据 DeepSeek 的 API 规范,多轮对话中必须将前一轮的
reasoning_content 原样传回
,否则后续请求会被拒绝。

当前 opencode 在工具调用流程中:

  1. 调用工具(如 LSP)获取结果
  2. 将工具结果作为新的 message 发送给 DeepSeek API
  3. 但没有保留前一轮 DeepSeek 返回的 reasoning_content
  4. 导致 DeepSeek API 拒绝请求

环境信息

  • opencode 版本: (1.15.10)
  • 操作系统: Ubuntu 24.04
  • provider: deepseek
  • 模型: deepseek-v4-pro 是否启用了 LSP: true

预期行为

使用 DeepSeek reasoning 模式时,工具调用后应该正常继续对话,不应出现 400 错误。

实际行为

任何需要工具调用的操作(LSP、MCP 等)在 DeepSeek reasoning 模式下都会触发 400 错误。

可能的修复方案

在调用 DeepSeek API 时:

  1. 保存 DeepSeek 返回的 reasoning_content 字段
  2. 在下一轮请求中,将 reasoning_content 原样放回 messages 中传给 API

Plugins

No response

OpenCode version

1.15.10

Steps to reproduce

  1. 配置 opencode 使用 DeepSeek provider(如 deepseek/deepseek-reasoner 或其他 reasoning 模型)
  2. 在任何项目中运行需要工具调用的操作(例如:@main.go 的 LSP 分析)
  3. opencode 调用 LSP 工具获取结果后,将结果发送给 DeepSeek API 进行下一轮处理
  4. DeepSeek API 返回 400 错误,因为 reasoning_content 没有从上一轮响应传回

Screenshot and/or share link

No response

Operating System

Ubuntu 24.04

Terminal

Windterm

Activity

  1. github-actions commented on May 23, 2026

    @github-actions
    Contributor

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

  2. arafays commented on May 23, 2026

    @arafays

    session.json

    here is session export I saw @rekram1-node asking for it @StarpTech this is the latest session started today!

  3. devcxl commented on May 26, 2026

    @devcxl

    我同样也遇到了这个错误 版本 1.15.10


    I have also encountered this error in version 1.15.10

    Image
  4. devcxl commented on May 27, 2026

    @devcxl

    已经两天了有人来解决下这个问题么?

    --

    It's been two days. Can anyone solve this problem?

    @StarpTech

  5. devcxl commented on May 27, 2026

    @devcxl

    在我的opencode-go订阅中没有办法使用deepseek-v4-pro/flash这感觉真是太糟糕了。


    It feels really bad that I don't have a way to use deepseek-v4-pro/flash with my opencode-go subscription.

  6. rekram1-node commented on May 29, 2026

    @rekram1-node
    Collaborator

    make sure that u have OPENCODE_EXPERIMENTAL_NATIVE_LLM=0, in some older versions OPENCODE_EXPERIMENTAL=1 would opt into the native llm experiment, which caused the issue that @arafays faced

    If u update or opt back out of native llm w/ OPENCODE_EXPERIMENTAL_NATIVE_LLM (its opted out by default) then this should go away

  7. rekram1-node commented on May 29, 2026

    @rekram1-node
    Collaborator

    @devcxl u were facing the same issue here too

  8. rekram1-node commented on May 29, 2026

    @rekram1-node
    Collaborator

    yup and OP was as well. This is "fixed" because native llm is opted out even if u have OPENCODE_EXPERIMENTAL set now, but just in case u can always also set OPENCODE_EXPERIMENTAL_NATIVE_LLM=0 to opt out

  9. devcxl commented on May 29, 2026

    @devcxl

    我升级了v1.15.11 这个问题似乎已经得到修复了 这是我之前设置的环境变量 @rekram1-node
    export OPENCODE_DISABLE_CLAUDE_CODE=1
    export OPENCODE_EXPERIMENTAL=1
    export OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true


    I upgraded to v1.15.11 and this problem seems to have been fixed. Here are the environment variables I set before. @rekram1-node
    export OPENCODE_DISABLE_CLAUDE_CODE=1
    export OPENCODE_EXPERIMENTAL=1
    export OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true

  10. devcxl commented on May 29, 2026

    @devcxl

    应该就是这个 OPENCODE_EXPERIMENTAL=1 导致的问题


    This should be the problem caused by OPENCODE_EXPERIMENTAL=1

  11. devcxl commented on May 29, 2026

    @devcxl

    @rekram1-node thanks for your work!

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