This commit is contained in:
allenliang2022 2026-09-07 23:22:33 -07:00 committed by GitHub
commit e80c1cfe9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 0 deletions

View file

@ -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,

View file

@ -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.