diff --git a/litellm/llms/github_copilot/responses/transformation.py b/litellm/llms/github_copilot/responses/transformation.py index 5a4bb798851..00e5d100d9e 100644 --- a/litellm/llms/github_copilot/responses/transformation.py +++ b/litellm/llms/github_copilot/responses/transformation.py @@ -240,6 +240,22 @@ class GithubCopilotResponsesAPIConfig(OpenAIResponsesAPIConfig): message=str(e), ) + def _validate_input_param( + self, input: Union[str, ResponseInputParam] + ) -> Union[str, ResponseInputParam]: + from litellm.litellm_core_utils.prompt_templates.common_utils import ( + filter_value_from_dict, + ) + + validated_input = super()._validate_input_param(input) + if isinstance(validated_input, list): + for item in validated_input: + if isinstance(item, dict): + filter_value_from_dict( + item, "internal_chat_message_metadata_passthrough" + ) + return validated_input + def get_complete_url( self, api_base: str | None, diff --git a/tests/test_litellm/llms/github_copilot/responses/test_github_copilot_responses_transformation.py b/tests/test_litellm/llms/github_copilot/responses/test_github_copilot_responses_transformation.py index 0174465b0cc..d7628831e75 100644 --- a/tests/test_litellm/llms/github_copilot/responses/test_github_copilot_responses_transformation.py +++ b/tests/test_litellm/llms/github_copilot/responses/test_github_copilot_responses_transformation.py @@ -317,6 +317,31 @@ class TestGithubCopilotResponsesAPITransformation: for param in expected_params: assert param in supported, f"{param} should be in supported params" + def test_transform_request_strips_codex_internal_metadata(self): + config = GithubCopilotResponsesAPIConfig() + transformed = config.transform_responses_api_request( + model="gpt-5.3-codex", + input=[ + { + "role": "user", + "content": "hello", + "internal_chat_message_metadata_passthrough": {"local": True}, + "nested": { + "internal_chat_message_metadata_passthrough": "remove-me", + "keep": "value", + }, + } + ], + response_api_optional_request_params={"max_output_tokens": 16}, + litellm_params={}, + headers={}, + ) + + input_item = transformed["input"][0] + assert "internal_chat_message_metadata_passthrough" not in input_item + assert "internal_chat_message_metadata_passthrough" not in input_item["nested"] + assert input_item["nested"]["keep"] == "value" + def test_handle_reasoning_item_preserves_encrypted_content(self): """Test that _handle_reasoning_item preserves encrypted_content for GitHub Copilot.