From a6c60e3cffb1ff1bdde710423d53d2aebccf7a84 Mon Sep 17 00:00:00 2001 From: Yufeng He <40085740+universeplayer@users.noreply.github.com> Date: Wed, 18 Mar 2026 13:54:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=87=E6=8D=A2=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=90=8E=20empty=20content=20=E5=AF=BC=E8=87=B4=20Gro?= =?UTF-8?q?k=20=E7=AD=89=20provider=20=E8=BF=94=E5=9B=9E=20400?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _finally_convert_payload 提取 think 部分后,如果 assistant 消息的 所有 content 都是 think 类型,new_content 会变成空列表 []。 Grok 等 provider 不接受空 content list,直接报 400。 改为 new_content or None,空列表时回退到 None(OpenAI 兼容 API 普遍接受 null content 的 assistant 消息)。 Fixes #6447 --- astrbot/core/provider/sources/openai_source.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index 2fae94e1a7..b3355668ee 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -604,8 +604,9 @@ def _finally_convert_payload(self, payloads: dict) -> None: reasoning_content += str(part.get("think")) else: new_content.append(part) - message["content"] = new_content - # reasoning key is "reasoning_content" + # Some providers (Grok, etc.) reject empty content lists. + # When all parts were think blocks, fall back to None. + message["content"] = new_content or None if reasoning_content: message["reasoning_content"] = reasoning_content