[GPT-OSS] Add support for arrays at tool message content (#25593)

Signed-off-by: Luis Tomas Bolivar <ltomasbo@redhat.com>
This commit is contained in:
Luis Tomas Bolivar
2025-10-10 11:00:45 +02:00
committed by GitHub
parent ad430a67ca
commit 3ee202ea1e
2 changed files with 139 additions and 0 deletions

View File

@@ -256,6 +256,13 @@ def parse_chat_input(chat_msg) -> list[Message]:
if role == "tool":
name = chat_msg.get("name", "")
content = chat_msg.get("content", "") or ""
if isinstance(content, list):
# Handle array format for tool message content
# by concatenating all text parts.
content = "".join(
item.get("text", "") for item in content
if isinstance(item, dict) and item.get("type") == "text")
msg = Message.from_author_and_content(
Author.new(Role.TOOL, f"functions.{name}"), content
).with_channel("commentary")