From cf1d71882304c5c37f9194c389ac2159c23a1c4a Mon Sep 17 00:00:00 2001 From: Teknium Date: Tue, 14 Apr 2026 20:47:06 -0700 Subject: [PATCH] fix: keep batch-path function_call_output.output as string per OpenAI spec The streaming path emits output as content-part arrays for Open WebUI compatibility, but the batch (non-streaming) Responses API path must return output as a plain string per the OpenAI Responses API spec. Reverts the _extract_output_items change from the cherry-picked commits while preserving the streaming path's array format. --- gateway/platforms/api_server.py | 7 +------ tests/gateway/test_api_server.py | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/gateway/platforms/api_server.py b/gateway/platforms/api_server.py index 62196973d..32c56d1fb 100644 --- a/gateway/platforms/api_server.py +++ b/gateway/platforms/api_server.py @@ -1949,15 +1949,10 @@ class APIServerAdapter(BasePlatformAdapter): "call_id": tc.get("id", ""), }) elif role == "tool": - output_content = msg.get("content", "") - if isinstance(output_content, list): - output = output_content - else: - output = [{"type": "input_text", "text": str(output_content)}] items.append({ "type": "function_call_output", "call_id": msg.get("tool_call_id", ""), - "output": output, + "output": msg.get("content", ""), }) # Final assistant message diff --git a/tests/gateway/test_api_server.py b/tests/gateway/test_api_server.py index 32346fc83..8e3e066b8 100644 --- a/tests/gateway/test_api_server.py +++ b/tests/gateway/test_api_server.py @@ -1547,7 +1547,7 @@ class TestToolCallsInOutput: assert output[0]["call_id"] == "call_abc123" assert output[1]["type"] == "function_call_output" assert output[1]["call_id"] == "call_abc123" - assert output[1]["output"] == [{"type": "input_text", "text": "42"}] + assert output[1]["output"] == "42" assert output[2]["type"] == "message" assert output[2]["content"][0]["text"] == "The result is 42."