perf: Set content to None when the OpenAI message content list is empty (#6551)

_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

Co-authored-by: Yufeng He <40085740+universeplayer@users.noreply.github.com>
This commit is contained in:
Yufeng He
2026-04-03 16:38:22 +08:00
committed by GitHub
parent 8f95ca9d98
commit 1408a8449e

View File

@@ -877,8 +877,9 @@ class ProviderOpenAIOfficial(Provider):
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