环境
- 系统:Fedora Linux 43 (KDE Plasma Desktop Edition), x86_64
- .NET: 10.0
- Chats.BE 版本:1.11.0
- 模型:DeepSeek v4 Pro
- API 路径:Anthropic Messages (
/v1/messages)
- Thinking 模式:已启用(
budget_tokens: 31999)
问题
通过 Anthropic Messages API 路径接入 DeepSeek v4 Pro,开启 thinking 模式后,当对话历史中存在同时包含 thinking 块和 tool_use 块的助手消息时,请求失败:
{
"error": {
"message": "The `content[].thinking` in the thinking mode must be passed back to the API.",
"type": "invalid_request_error"
}
}
根因
AnthropicChatService.ConvertMessages() 硬编码了只有 WebChat 来源才保留 thinking 块:
bool reallyAllowThinkingBlocks = allowThinkingBlocks && source == UsageSource.WebChat;
非 WebChat 来源(如 Claude Code API 调用)下,NeutralThinkContent 被全部丢弃,导致 DeepSeek 收到缺少 thinking 块的请求而报错。
关键文件
Services/Models/ChatServices/Anthropic/AnthropicChatService.cs — ConvertMessages() 第567行
Services/Models/ChatServices/Anthropic/DeepSeekAnthropicService.cs — 仅重写 GetEndpointAndKey()
复现步骤
- 配置 DeepSeek v4 Pro,
DBApiType: AnthropicMessages,DBModelProvider: DeepSeek
- 开启 thinking(设置
ThinkingBudget)
- 通过
/v1/messages 发送多轮对话,前一轮助手消息包含 thinking + tool_use
- DeepSeek 返回上述错误
环境
/v1/messages)budget_tokens: 31999)问题
通过 Anthropic Messages API 路径接入 DeepSeek v4 Pro,开启 thinking 模式后,当对话历史中存在同时包含
thinking块和tool_use块的助手消息时,请求失败:{ "error": { "message": "The `content[].thinking` in the thinking mode must be passed back to the API.", "type": "invalid_request_error" } }根因
AnthropicChatService.ConvertMessages()硬编码了只有 WebChat 来源才保留 thinking 块:非 WebChat 来源(如 Claude Code API 调用)下,
NeutralThinkContent被全部丢弃,导致 DeepSeek 收到缺少 thinking 块的请求而报错。关键文件
Services/Models/ChatServices/Anthropic/AnthropicChatService.cs—ConvertMessages()第567行Services/Models/ChatServices/Anthropic/DeepSeekAnthropicService.cs— 仅重写GetEndpointAndKey()复现步骤
DBApiType: AnthropicMessages,DBModelProvider: DeepSeekThinkingBudget)/v1/messages发送多轮对话,前一轮助手消息包含thinking+tool_use