From f26a9fe4b64ea9877f58cfa620285989b6af8b63 Mon Sep 17 00:00:00 2001 From: "Alexandr A. Alexandrov" Date: Thu, 17 Sep 2026 21:39:12 +0000 Subject: [PATCH] fix(chatgpt): omit unsupported previous response ids --- .../llms/chatgpt/responses/transformation.py | 1 - .../test_chatgpt_responses_transformation.py | 23 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/litellm/llms/chatgpt/responses/transformation.py b/litellm/llms/chatgpt/responses/transformation.py index 34953a79c60..c1c4c99536e 100644 --- a/litellm/llms/chatgpt/responses/transformation.py +++ b/litellm/llms/chatgpt/responses/transformation.py @@ -108,7 +108,6 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig): "tools", "tool_choice", "reasoning", - "previous_response_id", "truncation", } diff --git a/tests/unit/llms/chatgpt/responses/test_chatgpt_responses_transformation.py b/tests/unit/llms/chatgpt/responses/test_chatgpt_responses_transformation.py index e47d7fc702c..3392657294a 100644 --- a/tests/unit/llms/chatgpt/responses/test_chatgpt_responses_transformation.py +++ b/tests/unit/llms/chatgpt/responses/test_chatgpt_responses_transformation.py @@ -189,6 +189,27 @@ class TestChatGPTResponsesAPITransformation: assert "reasoning.encrypted_content" in request["include"] assert request["instructions"].startswith("You are Codex, based on GPT-5.") + def test_chatgpt_omits_foreign_previous_response_id(self): + config = ChatGPTResponsesAPIConfig() + input_items = [ + { + "type": "message", + "role": "user", + "content": [{"type": "input_text", "text": "continue"}], + } + ] + + request = config.transform_responses_api_request( + model="chatgpt/gpt-5.6-sol", + input=input_items, + response_api_optional_request_params={"previous_response_id": "resp_foreign_fixture"}, + litellm_params=GenericLiteLLMParams(), + headers={}, + ) + + assert "previous_response_id" not in request + assert request["input"] == input_items + @pytest.mark.parametrize( "model_name", [ @@ -230,7 +251,7 @@ class TestChatGPTResponsesAPITransformation: assert "stream_options" not in request assert request["truncation"] == "auto" - assert request["previous_response_id"] == "resp_123" + assert "previous_response_id" not in request assert request["reasoning"] == {"effort": "medium"} assert request["tools"] == [{"type": "function", "function": {"name": "hello"}}] assert request["tool_choice"] == {