From a4a1079510a4c8ad4ec2765ef38ec21716523ce1 Mon Sep 17 00:00:00 2001 From: Stephen Chin <1290231+steveonjava@users.noreply.github.com> Date: Thu, 20 Aug 2026 06:20:50 -0700 Subject: [PATCH] fix(chatgpt): forward native compaction config --- litellm/llms/chatgpt/responses/transformation.py | 1 + .../responses/test_chatgpt_responses_transformation.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/litellm/llms/chatgpt/responses/transformation.py b/litellm/llms/chatgpt/responses/transformation.py index da4c5598d80..62dfd65fd6c 100644 --- a/litellm/llms/chatgpt/responses/transformation.py +++ b/litellm/llms/chatgpt/responses/transformation.py @@ -98,6 +98,7 @@ class ChatGPTResponsesAPIConfig(OpenAIResponsesAPIConfig): "tool_choice", "reasoning", "prompt_cache_key", + "context_management", "previous_response_id", "truncation", } diff --git a/tests/test_litellm/llms/chatgpt/responses/test_chatgpt_responses_transformation.py b/tests/test_litellm/llms/chatgpt/responses/test_chatgpt_responses_transformation.py index efced02dbaf..f8f485467b8 100644 --- a/tests/test_litellm/llms/chatgpt/responses/test_chatgpt_responses_transformation.py +++ b/tests/test_litellm/llms/chatgpt/responses/test_chatgpt_responses_transformation.py @@ -124,14 +124,12 @@ class TestChatGPTResponsesAPITransformation: "user": "user_123", "temperature": 0.2, "top_p": 0.9, - "context_management": [ - {"type": "compaction", "compact_threshold": 200000} - ], "metadata": {"foo": "bar"}, "max_output_tokens": 123, "stream_options": {"include_usage": True}, # supported and should be preserved "prompt_cache_key": "session_123", + "context_management": [{"type": "compaction", "compact_threshold": 200000}], "truncation": "auto", "previous_response_id": "resp_123", "reasoning": {"effort": "medium"}, @@ -145,12 +143,14 @@ class TestChatGPTResponsesAPITransformation: assert "user" not in request assert "temperature" not in request assert "top_p" not in request - assert "context_management" not in request assert "metadata" not in request assert "max_output_tokens" not in request assert "stream_options" not in request assert request["prompt_cache_key"] == "session_123" + assert request["context_management"] == [ + {"type": "compaction", "compact_threshold": 200000} + ] assert request["truncation"] == "auto" assert request["previous_response_id"] == "resp_123" assert request["reasoning"] == {"effort": "medium"}