From 7c80dd2d22f4d771f7eef6b2b188caa03cac4d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E6=99=93=E6=9B=A6?= Date: Fri, 24 Apr 2026 14:08:02 +0800 Subject: [PATCH] fix: set empty reasoning_content for DeepSeek when tool_calls present When the model returns tool_calls alongside reasoning_content, some DeepSeek models (e.g., deepseek-v4-flash) include non-empty reasoning_content which can cause downstream issues. Apply the same empty-string normalization already done for Kimi models. --- run_agent.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run_agent.py b/run_agent.py index affcbbd721..83eeedd2d8 100644 --- a/run_agent.py +++ b/run_agent.py @@ -7283,13 +7283,17 @@ class AIAgent: api_msg["reasoning_content"] = normalized_reasoning return + deepseek_requires_reasoning = ( + self.provider in {"deepseek", "custom"} + and base_url_host_matches(self.base_url, "api.deepseek.com") + ) kimi_requires_reasoning = ( self.provider in {"kimi-coding", "kimi-coding-cn"} or base_url_host_matches(self.base_url, "api.kimi.com") or base_url_host_matches(self.base_url, "moonshot.ai") or base_url_host_matches(self.base_url, "moonshot.cn") ) - if kimi_requires_reasoning and source_msg.get("tool_calls"): + if (kimi_requires_reasoning or deepseek_requires_reasoning) and source_msg.get("tool_calls"): api_msg["reasoning_content"] = "" @staticmethod