From 4264079089a61ef90e09011fb8add37ead4af20e Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 8 Oct 2026 02:49:24 -0700 Subject: [PATCH 1/2] fix(responses): join function_call_output text parts with a newline in the chat-completions bridge --- .../litellm_completion_transformation/transformation.py | 2 +- .../test_function_call_output_normalization.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.py index b1dc6b3a98a..9bd8373f62a 100644 --- a/litellm/responses/litellm_completion_transformation/transformation.py +++ b/litellm/responses/litellm_completion_transformation/transformation.py @@ -1639,7 +1639,7 @@ class LiteLLMCompletionResponsesConfig: # Ensure we include any accumulated text as text blocks too return normalized_blocks if text_acc: - return "".join(text_acc) + return "\n".join(text_acc) try: # last resort: keep something meaningful for providers that require a string import json as _json diff --git a/tests/unit/responses/litellm_completion_transformation/test_function_call_output_normalization.py b/tests/unit/responses/litellm_completion_transformation/test_function_call_output_normalization.py index 3af1ef51e3e..bbcba0d5312 100644 --- a/tests/unit/responses/litellm_completion_transformation/test_function_call_output_normalization.py +++ b/tests/unit/responses/litellm_completion_transformation/test_function_call_output_normalization.py @@ -11,14 +11,14 @@ from litellm.responses.litellm_completion_transformation.transformation import ( ) -def test_function_call_output_list_input_text_is_converted_to_tool_string_content(): +def test_function_call_output_list_input_text_parts_reach_the_tool_message_on_separate_lines(): out = LiteLLMCompletionResponsesConfig._transform_responses_api_tool_call_output_to_chat_completion_message( tool_call_output={ "type": "function_call_output", "call_id": "call_1", "output": [ - {"type": "input_text", "text": "hello"}, - {"type": "input_text", "text": " world"}, + {"type": "input_text", "text": "Paris: 22 degrees"}, + {"type": "input_text", "text": "clear skies"}, ], } ) @@ -27,7 +27,7 @@ def test_function_call_output_list_input_text_is_converted_to_tool_string_conten msg = out[0] assert msg["role"] == "tool" assert msg["tool_call_id"] == "call_1" - assert msg["content"] == "hello world" + assert msg["content"] == "Paris: 22 degrees\nclear skies" def test_function_call_output_string_passthrough(): From 574b96aefb8bbe35ed5c2c9d547ea6f564759639 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 8 Oct 2026 04:09:36 -0700 Subject: [PATCH 2/2] test(responses): pin that a text part's leading whitespace survives the newline join --- .../test_function_call_output_normalization.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/unit/responses/litellm_completion_transformation/test_function_call_output_normalization.py b/tests/unit/responses/litellm_completion_transformation/test_function_call_output_normalization.py index bbcba0d5312..1a0b8d34ee0 100644 --- a/tests/unit/responses/litellm_completion_transformation/test_function_call_output_normalization.py +++ b/tests/unit/responses/litellm_completion_transformation/test_function_call_output_normalization.py @@ -30,6 +30,21 @@ def test_function_call_output_list_input_text_parts_reach_the_tool_message_on_se assert msg["content"] == "Paris: 22 degrees\nclear skies" +def test_function_call_output_text_part_whitespace_survives_the_join(): + out = LiteLLMCompletionResponsesConfig._transform_responses_api_tool_call_output_to_chat_completion_message( + tool_call_output={ + "type": "function_call_output", + "call_id": "call_1", + "output": [ + {"type": "input_text", "text": "hello"}, + {"type": "input_text", "text": " world"}, + ], + } + ) + + assert out[0]["content"] == "hello\n world" + + def test_function_call_output_string_passthrough(): out = LiteLLMCompletionResponsesConfig._transform_responses_api_tool_call_output_to_chat_completion_message( tool_call_output={