From 0c7c2b41ef1b45e071cf51eaec51a188375f1bfb Mon Sep 17 00:00:00 2001 From: codex Date: Fri, 16 Jan 2026 02:16:28 +0000 Subject: [PATCH] fix: flatten assistant content for openai payload --- astrbot/core/provider/sources/openai_source.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index 2544782f4..0364add8b 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -371,12 +371,21 @@ def _finally_convert_payload(self, payloads: dict): ): reasoning_content = "" new_content = [] # not including think part + text_parts = [] + has_non_text = False for part in message["content"]: if part.get("type") == "think": reasoning_content += str(part.get("think")) else: new_content.append(part) - message["content"] = new_content + if part.get("type") == "text": + text_parts.append(str(part.get("text", ""))) + else: + has_non_text = True + if not has_non_text: + message["content"] = "".join(text_parts) + else: + message["content"] = new_content # reasoning key is "reasoning_content" if reasoning_content: message["reasoning_content"] = reasoning_content