From 79283a201f9bbe1070f03c1333e77f687c05ea34 Mon Sep 17 00:00:00 2001 From: stmanst <52804599+truongsontung@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:17:38 +0700 Subject: [PATCH 1/4] fix(responses): ensure reasoning output items have summary=[] not null OpenAI Responses API spec requires reasoning output items to have a 'summary' field as an array. LiteLLM was emitting null instead of [], causing strict SDK clients to crash when trying to iterate over the summary. Fixes #40519 --- .../litellm_completion_transformation/transformation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.py index b2d1a69e0d8..c720307179e 100644 --- a/litellm/responses/litellm_completion_transformation/transformation.py +++ b/litellm/responses/litellm_completion_transformation/transformation.py @@ -2410,6 +2410,7 @@ class LiteLLMCompletionResponsesConfig: for text in (reasoning_content,) if text ], + summary=[], encrypted_content=encrypted_content, ) ] From 128b04d049a8381a8372f18041174e601b7dbf12 Mon Sep 17 00:00:00 2001 From: stmanst <52804599+truongsontung@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:23:21 +0700 Subject: [PATCH 2/4] test(responses): add regression test for non-null reasoning summary --- .../test_litellm_completion_responses.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py index 2068f10ea2d..2d0d37f9fff 100644 --- a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py +++ b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py @@ -335,6 +335,9 @@ class TestLiteLLMCompletionResponsesConfig: assert reasoning_item.content[0].type == "output_text" assert "step by step" in reasoning_item.content[0].text assert "42" in reasoning_item.content[0].text + # Regression for #40519: summary must be an empty array, not null + assert hasattr(reasoning_item, "summary"), "reasoning item should have summary attribute" + assert reasoning_item.summary == [], f"summary should be empty list, got {reasoning_item.summary}" message_items = [ item for item in responses_api_response.output if item.type == "message" @@ -4020,6 +4023,20 @@ class TestBridgedOutputItemIdPrefixes: assert not suffix.lstrip("-").isdigit() assert not suffix.startswith("-") + def test_reasoning_item_summary_is_empty_list_not_null(self): + """Regression: reasoning output items must have summary as a list, not null. + + OpenAI Responses API spec requires reasoning items to have a 'summary' + field as an array. LiteLLM was emitting null instead of [], causing + strict SDK clients to crash when trying to iterate over the summary. + """ + items = self._reasoning_items() + assert len(items) == 1 + summary = getattr(items[0], "summary", None) + assert summary is not None, "summary should not be None (regression for #40519)" + assert isinstance(summary, list), f"summary should be a list, got {type(summary)}" + assert summary == [], f"summary should be an empty list, got {summary}" + class TestStreamingSnapshotItemIds: """The response.completed snapshot must reuse the streamed item ID (issue #27333). From 605fb4e760789ec0449619ff8f8f0e1002045fb7 Mon Sep 17 00:00:00 2001 From: stmanst <52804599+truongsontung@users.noreply.github.com> Date: Thu, 10 Sep 2026 10:32:16 +0700 Subject: [PATCH 3/4] test(responses): add regression test for non-null reasoning summary --- .../test_litellm_completion_responses.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py index 2d0d37f9fff..dc80b01852b 100644 --- a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py +++ b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py @@ -4023,6 +4023,22 @@ class TestBridgedOutputItemIdPrefixes: assert not suffix.lstrip("-").isdigit() assert not suffix.startswith("-") + def test_reasoning_item_summary_is_empty_list_not_null(self): + """Regression: reasoning output items must have summary as an empty array, not null. + + OpenAI Responses API spec requires reasoning items to have a 'summary' + field as an array. A null summary causes strict SDK clients to crash. + See issue #40519. + """ + items = self._reasoning_items() + assert len(items) == 1 + # summary must be an empty list, never None/null + summary = getattr(items[0], "summary", "MISSING") + assert summary is not "MISSING", "summary attribute should be present" + assert summary is not None, "summary should not be None" + assert isinstance(summary, list), f"summary should be a list, got {type(summary)}" + assert summary == [], f"summary should be an empty list, got {summary}" + def test_reasoning_item_summary_is_empty_list_not_null(self): """Regression: reasoning output items must have summary as a list, not null. From 91531c02f4d7160bd98c917195c61773d2fd6de1 Mon Sep 17 00:00:00 2001 From: stmanst <52804599+truongsontung@users.noreply.github.com> Date: Thu, 10 Sep 2026 19:18:18 +0700 Subject: [PATCH 4/4] fix: remove duplicate test and fix lint E721 string comparison --- .../test_litellm_completion_responses.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py index dc80b01852b..43ea06af5fc 100644 --- a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py +++ b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py @@ -4034,25 +4034,11 @@ class TestBridgedOutputItemIdPrefixes: assert len(items) == 1 # summary must be an empty list, never None/null summary = getattr(items[0], "summary", "MISSING") - assert summary is not "MISSING", "summary attribute should be present" + assert summary != "MISSING", "summary attribute should be present" assert summary is not None, "summary should not be None" assert isinstance(summary, list), f"summary should be a list, got {type(summary)}" assert summary == [], f"summary should be an empty list, got {summary}" - def test_reasoning_item_summary_is_empty_list_not_null(self): - """Regression: reasoning output items must have summary as a list, not null. - - OpenAI Responses API spec requires reasoning items to have a 'summary' - field as an array. LiteLLM was emitting null instead of [], causing - strict SDK clients to crash when trying to iterate over the summary. - """ - items = self._reasoning_items() - assert len(items) == 1 - summary = getattr(items[0], "summary", None) - assert summary is not None, "summary should not be None (regression for #40519)" - assert isinstance(summary, list), f"summary should be a list, got {type(summary)}" - assert summary == [], f"summary should be an empty list, got {summary}" - class TestStreamingSnapshotItemIds: """The response.completed snapshot must reuse the streamed item ID (issue #27333).