From 2bd527e62ea2f3d1ba097fdf801988063adc2186 Mon Sep 17 00:00:00 2001 From: yuneng-jiang Date: Sat, 14 Mar 2026 15:19:14 -0700 Subject: [PATCH] [Fix] Prevent second responses_api_bridge_check from overwriting first The second `responses_api_bridge_check` call unconditionally overwrote `responses_api_model_info` set by the first call. For models using the `responses/` prefix (e.g. `azure/responses/`), the first check correctly detected `mode: "responses"` and stripped the prefix, but the second check then overwrote it with an empty dict since the model no longer started with `responses/`. Skip the second check when the first already detected responses mode. Co-Authored-By: Claude Opus 4.6 --- litellm/main.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/litellm/main.py b/litellm/main.py index a9a1c38e3f..60d411c98a 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -1613,13 +1613,18 @@ def completion( # type: ignore # noqa: PLR0915 ) ## RESPONSES API BRIDGE LOGIC ## - check if model has 'mode: responses' in litellm.model_cost map - responses_api_model_info, model = responses_api_bridge_check( - model=model, - custom_llm_provider=custom_llm_provider, - web_search_options=web_search_options, - tools=tools, - reasoning_effort=reasoning_effort, - ) + # Only run the second bridge check if the first one didn't already + # detect responses mode (e.g. via the "responses/" prefix). The second + # check handles cases like gpt-5.4+ with tools+reasoning_effort that + # the first (early) check doesn't cover. + if responses_api_model_info.get("mode") != "responses": + responses_api_model_info, model = responses_api_bridge_check( + model=model, + custom_llm_provider=custom_llm_provider, + web_search_options=web_search_options, + tools=tools, + reasoning_effort=reasoning_effort, + ) if responses_api_model_info.get("mode") == "responses": from litellm.completion_extras import responses_api_bridge