From 5d41295c2a96404a49ece425f75f56a8ac1fd9e1 Mon Sep 17 00:00:00 2001 From: mateo Date: Sun, 13 Sep 2026 04:15:07 +0000 Subject: [PATCH] fix: preserve explicit native endpoint opt-in Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../messages/handler.py | 16 ++++------------ litellm/responses/main.py | 17 +++-------------- .../test_native_endpoint_forwarding.py | 19 ------------------- .../test_responses_prompt_management.py | 8 ++++---- 4 files changed, 11 insertions(+), 49 deletions(-) diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/handler.py b/litellm/llms/anthropic/experimental_pass_through/messages/handler.py index e17b431cf34..0548abaa2ff 100644 --- a/litellm/llms/anthropic/experimental_pass_through/messages/handler.py +++ b/litellm/llms/anthropic/experimental_pass_through/messages/handler.py @@ -31,7 +31,7 @@ from litellm.types.llms.anthropic_messages.anthropic_response import ( AnthropicMessagesResponse, ) from litellm.types.router import GenericLiteLLMParams -from litellm.types.utils import CallTypes, LlmProviders +from litellm.types.utils import CallTypes from litellm.utils import ProviderConfigManager, client from ..adapters.handler import LiteLLMMessagesToCompletionTransformationHandler @@ -567,7 +567,7 @@ def anthropic_messages_handler( provider=litellm.LlmProviders(custom_llm_provider), ) if anthropic_messages_provider_config is None and _deployment_supports_native_anthropic_messages( - kwargs.get("model_info"), model=model, custom_llm_provider=custom_llm_provider + kwargs.get("model_info") ): from litellm.llms.openai_like.messages.transformation import ( OpenAILikeAnthropicMessagesConfig, @@ -666,13 +666,5 @@ def anthropic_messages_handler( ) -def _deployment_supports_native_anthropic_messages( - model_info: object, model: str | None, custom_llm_provider: str | None -) -> bool: - if _deployment_passes_through_anthropic_messages(model_info): - return True - if model is None or custom_llm_provider not in tuple(provider.value for provider in LlmProviders): - return False - from litellm.utils import model_supports_native_endpoint - - return model_supports_native_endpoint("/v1/messages", model, LlmProviders(custom_llm_provider)) +def _deployment_supports_native_anthropic_messages(model_info: object) -> bool: + return _deployment_passes_through_anthropic_messages(model_info) diff --git a/litellm/responses/main.py b/litellm/responses/main.py index 6d5b46d913b..73bbb334537 100644 --- a/litellm/responses/main.py +++ b/litellm/responses/main.py @@ -52,7 +52,6 @@ from litellm.llms.openai.data_residency import infer_openai_data_residency from litellm.secret_managers.main import get_secret_str from litellm.types.responses.main import * from litellm.types.router import GenericLiteLLMParams -from litellm.types.utils import LlmProviders from litellm.utils import ( ProviderConfigManager, client, @@ -467,9 +466,7 @@ def _resolve_responses_api_provider_config( provider_config: Final = ProviderConfigManager.get_provider_responses_api_config( model=model, provider=custom_llm_provider ) - if provider_config is not None or not _deployment_supports_native_responses( - model_info, model=model, custom_llm_provider=custom_llm_provider - ): + if provider_config is not None or not _deployment_supports_native_responses(model_info): return provider_config return OpenAILikeResponsesConfig() @@ -2296,13 +2293,5 @@ async def _aresponses_websocket( ) -def _deployment_supports_native_responses( - model_info: object, model: str | None, custom_llm_provider: str | None -) -> bool: - if _deployment_passes_through_responses(model_info): - return True - if model is None or custom_llm_provider not in tuple(provider.value for provider in LlmProviders): - return False - from litellm.utils import model_supports_native_endpoint - - return model_supports_native_endpoint("/v1/responses", model, LlmProviders(custom_llm_provider)) +def _deployment_supports_native_responses(model_info: object) -> bool: + return _deployment_passes_through_responses(model_info) diff --git a/tests/test_litellm/llms/bedrock/test_native_endpoint_forwarding.py b/tests/test_litellm/llms/bedrock/test_native_endpoint_forwarding.py index 117179cebe4..a577673a15a 100644 --- a/tests/test_litellm/llms/bedrock/test_native_endpoint_forwarding.py +++ b/tests/test_litellm/llms/bedrock/test_native_endpoint_forwarding.py @@ -5,9 +5,6 @@ import httpx import pytest import litellm -from litellm.llms.anthropic.experimental_pass_through.messages.handler import ( - _deployment_supports_native_anthropic_messages, -) from litellm.llms.bedrock.chat.openai_chat_completions_transformation import ( AmazonBedrockOpenAIChatCompletionsConfig, ) @@ -17,7 +14,6 @@ from litellm.llms.bedrock.messages.native_transformation import ( mantle_native_messages_config, ) from litellm.llms.bedrock.responses.transformation import AmazonBedrockResponsesAPIConfig -from litellm.responses.main import _deployment_supports_native_responses from litellm.types.utils import LlmProviders from litellm.utils import ProviderConfigManager, model_supports_native_endpoint @@ -265,21 +261,6 @@ def test_native_responses_selection_and_url(monkeypatch): ) is None -def test_generic_endpoint_helpers_read_cost_map(monkeypatch): - monkeypatch.setitem( - litellm.model_cost, - "hosted_vllm/native-model", - {"supported_endpoints": ["/v1/messages", "/v1/responses"]}, # mutable-ok: provider interface - ) - - assert _deployment_supports_native_anthropic_messages( - None, model="native-model", custom_llm_provider="hosted_vllm" - ) - assert _deployment_supports_native_responses( - None, model="native-model", custom_llm_provider="hosted_vllm" - ) - - def test_completion_forwards_native_chat_body(monkeypatch): monkeypatch.setitem( litellm.model_cost, diff --git a/tests/test_litellm/responses/test_responses_prompt_management.py b/tests/test_litellm/responses/test_responses_prompt_management.py index 4dba303073a..530afbd856b 100644 --- a/tests/test_litellm/responses/test_responses_prompt_management.py +++ b/tests/test_litellm/responses/test_responses_prompt_management.py @@ -320,7 +320,7 @@ class TestResponsesAPIPromptManagement: def test_cache_control_hook_preserves_reasoning_items(self): original_input, merged_messages, reasoning_item = _make_cache_control_case() logging_obj = _make_logging_obj( - merged_model="azure/prompt-management-test-model", + merged_model="azure/gpt-5-codex", merged_messages=merged_messages, ) @@ -330,7 +330,7 @@ class TestResponsesAPIPromptManagement: litellm.responses( input=original_input, - model="azure/prompt-management-test-model", + model="azure/gpt-5-codex", litellm_logging_obj=logging_obj, cache_control_injection_points=[{"location": "message", "role": "system"}], ) @@ -516,7 +516,7 @@ class TestAsyncResponsesAPIPromptManagement: async def test_async_cache_control_hook_preserves_reasoning_items(self): original_input, merged_messages, reasoning_item = _make_cache_control_case() logging_obj = _make_logging_obj( - merged_model="azure/prompt-management-test-model", + merged_model="azure/gpt-5-codex", merged_messages=merged_messages, ) @@ -526,7 +526,7 @@ class TestAsyncResponsesAPIPromptManagement: await litellm.aresponses( input=original_input, - model="azure/prompt-management-test-model", + model="azure/gpt-5-codex", litellm_logging_obj=logging_obj, cache_control_injection_points=[{"location": "message", "role": "system"}], )