From 5ae608152ec420d249b44542051ac27989fd33b0 Mon Sep 17 00:00:00 2001 From: codez Date: Sun, 26 Apr 2026 06:08:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20remove=20has=5Freasoning=20guard=20?= =?UTF-8?q?=E2=80=94=20inject=20empty=20reasoning=5Fcontent=20for=20DeepSe?= =?UTF-8?q?ek/Kimi=20tool=5Fcalls=20unconditionally?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- run_agent.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/run_agent.py b/run_agent.py index e9e100521..23cb08821 100644 --- a/run_agent.py +++ b/run_agent.py @@ -7752,16 +7752,13 @@ class AIAgent: api_msg["reasoning_content"] = existing return - # 2. DeepSeek / Kimi thinking mode: tool-call turns with neither - # reasoning_content nor reasoning are "poisoned history" — a prior - # provider (MiniMax, etc.) left them empty. DeepSeek returns HTTP 400 - # if reasoning_content is absent on replay. Inject "" to satisfy the - # provider's requirement without forwarding cross-provider content. - normalized_reasoning = source_msg.get("reasoning") - has_reasoning = isinstance(normalized_reasoning, str) and bool(normalized_reasoning.strip()) + # 2. DeepSeek / Kimi thinking mode: tool-call turns that lack + # reasoning_content are "poisoned history" — a prior provider (MiniMax, + # etc.) left them empty. DeepSeek returns HTTP 400 if reasoning_content + # is absent on replay; inject "" to satisfy the provider's requirement + # without forwarding any cross-provider reasoning content. needs_empty_reasoning = ( - not has_reasoning - and source_msg.get("tool_calls") + source_msg.get("tool_calls") and ( self._needs_kimi_tool_reasoning() or self._needs_deepseek_tool_reasoning()