From be2489114f04054204b89133da6863fb945ff60b Mon Sep 17 00:00:00 2001 From: michelligabriele Date: Fri, 16 Oct 2026 15:03:08 +0200 Subject: [PATCH] fix(hosted_vllm): map developer items in _validate_input_param so compact requests are covered too --- .../hosted_vllm/responses/transformation.py | 17 ++--------------- .../responses/test_hosted_vllm_responses.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/litellm/llms/hosted_vllm/responses/transformation.py b/litellm/llms/hosted_vllm/responses/transformation.py index fafc9f96210..d32191aeec9 100644 --- a/litellm/llms/hosted_vllm/responses/transformation.py +++ b/litellm/llms/hosted_vllm/responses/transformation.py @@ -93,21 +93,8 @@ class HostedVLLMResponsesAPIConfig(OpenAIResponsesAPIConfig): return f"{api_base}/v1/responses" - def transform_responses_api_request( - self, - model: str, - input: str | ResponseInputParam, - response_api_optional_request_params: dict, # mutable-ok: overrides the base class signature - litellm_params: GenericLiteLLMParams, - headers: dict, # mutable-ok: overrides the base class signature - ) -> dict: # mutable-ok: overrides the base class signature - return super().transform_responses_api_request( - model=model, - input=_developer_items_as_system(self._validate_input_param(input)), - response_api_optional_request_params=response_api_optional_request_params, - litellm_params=litellm_params, - headers=headers, - ) + def _validate_input_param(self, input: str | ResponseInputParam) -> str | ResponseInputParam: + return _developer_items_as_system(super()._validate_input_param(input)) def supports_native_websocket(self) -> bool: """Hosted vLLM does not support native WebSocket for Responses API""" diff --git a/tests/unit/llms/hosted_vllm/responses/test_hosted_vllm_responses.py b/tests/unit/llms/hosted_vllm/responses/test_hosted_vllm_responses.py index af229aa516c..9a466ca5917 100644 --- a/tests/unit/llms/hosted_vllm/responses/test_hosted_vllm_responses.py +++ b/tests/unit/llms/hosted_vllm/responses/test_hosted_vllm_responses.py @@ -287,6 +287,25 @@ def test_hosted_vllm_responses_passes_string_input_and_instructions_through() -> assert request["instructions"] == CODEX_INSTRUCTIONS +def test_hosted_vllm_compact_request_sends_developer_items_as_system() -> None: + url, data = HostedVLLMResponsesAPIConfig().transform_compact_response_api_request( + model="kimi-k3", + input=[ + {"type": "message", "role": "developer", "content": CODEX_INSTRUCTIONS}, + {"type": "message", "role": "user", "content": "summarize the session"}, + ], + response_api_optional_request_params={}, + api_base=f"{VLLM_API_BASE}/responses", + litellm_params=GenericLiteLLMParams(), + headers={}, + ) + assert url == f"{VLLM_API_BASE}/responses/compact" + assert data["input"] == [ + {"type": "message", "role": "system", "content": CODEX_INSTRUCTIONS}, + {"type": "message", "role": "user", "content": "summarize the session"}, + ] + + @pytest.fixture def vllm_responses_route(respx_mock: respx.MockRouter, monkeypatch: pytest.MonkeyPatch) -> respx.Route: monkeypatch.setattr(litellm, "disable_aiohttp_transport", True)