From 4fd1d2cd10db20bca2f76f49b7ec511b0e52ec70 Mon Sep 17 00:00:00 2001 From: Anish Gurjar <50738829+anishgurjar@users.noreply.github.com> Date: Wed, 21 Oct 2026 17:49:06 -0400 Subject: [PATCH 1/3] test: cover httpx.Timeout preservation for shared-handler providers --- .../test_completion_timeout_resolution.py | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tests/unit/test_completion_timeout_resolution.py b/tests/unit/test_completion_timeout_resolution.py index 37b5cceef5a..2f101336c7a 100644 --- a/tests/unit/test_completion_timeout_resolution.py +++ b/tests/unit/test_completion_timeout_resolution.py @@ -143,6 +143,75 @@ def test_httpx_timeout_coerced_for_provider_without_httpx_timeout_support(): assert not isinstance(out, httpx.Timeout) +SHARED_HTTPX_HANDLER_PROVIDERS: Final = ( + "a2a", + "anthropic_text", + "bedrock_mantle", + "bytez", + "cloudflare", + "cohere", + "cohere_chat", + "cometapi", + "compactifai", + "databricks", + "databricks_agent", + "datarobot", + "deepseek", + "edenai", + "fal_ai", + "fireworks_ai", + "gdc", + "gigachat", + "gradient_ai", + "groq", + "heroku", + "hosted_vllm", + "huggingface", + "langflow", + "langgraph", + "lemonade", + "minimax", + "mistral", + "nadir", + "oci", + "ollama", + "ollama_chat", + "openrouter", + "ovhcloud", + "ragflow", + "scaledown", + "snowflake", + "text-completion-codestral", + "together_ai", + "triton", + "vercel_ai_gateway", + "watsonx_text", + "xai", +) + + +@pytest.mark.parametrize("provider", SHARED_HTTPX_HANDLER_PROVIDERS) +def test_httpx_timeout_preserved_for_shared_httpx_handler_providers(provider: str) -> None: + """Providers dispatched to the shared httpx handler accept httpx.Timeout (issue #47822).""" + assert supports_httpx_timeout(provider) is True + t: Final = httpx.Timeout(40.0, connect=5.0) + resolved: Final = CompletionTimeout.resolve( + t, + {}, + provider, + global_timeout=None, + supports_httpx_timeout=supports_httpx_timeout, + stream_kind=StreamKind.NOT_STREAMED, + ) + assert resolved is t + + +@pytest.mark.parametrize("provider", ("azure_ai", "vertex_ai", "anthropic", "gemini", "watsonx")) +def test_httpx_timeout_still_coerced_for_sdk_providers(provider: str) -> None: + """Providers on third-party SDKs keep the float coercion.""" + assert supports_httpx_timeout(provider) is False + + def test_httpx_timeout_preserved_for_openai(): t = httpx.Timeout(40.0, connect=5.0) out = CompletionTimeout.resolve( From d9d5932a703530e9978a4c703e78b47fd071c5e3 Mon Sep 17 00:00:00 2001 From: Anish Gurjar <50738829+anishgurjar@users.noreply.github.com> Date: Wed, 21 Oct 2026 17:52:25 -0400 Subject: [PATCH 2/3] fix: honor httpx.Timeout for providers on the shared httpx handler --- litellm/utils.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/litellm/utils.py b/litellm/utils.py index 7de7ce6188d..6bd0f905dc5 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2849,13 +2849,72 @@ def token_counter( def supports_httpx_timeout(custom_llm_provider: str) -> bool: """ Helper function to know if a provider implementation supports httpx timeout + + A provider supports ``httpx.Timeout`` when its completion is dispatched to + LiteLLM's own httpx clients (``AsyncHTTPHandler``/``HTTPHandler`` accept + ``float | httpx.Timeout``): the shared ``BaseLLMHTTPHandler.completion`` + path in ``main.py``, or the ``CodestralTextCompletion`` handler which uses + ``AsyncHTTPHandler`` directly. Providers routed through third-party SDKs + that expect a plain float (for example ``vertex_ai``, ``anthropic``, + ``azure_ai``, ``gemini``) are intentionally not listed, and neither are + OpenAI-SDK-based OpenAI-compatible providers (handled conservatively for + now, matching the pre-existing ``openai``/``azure`` coverage). """ - supported_providers: Final = ["openai", "azure", "bedrock"] + supported_providers: Final = [ + # SDK clients that accept httpx.Timeout natively + "openai", + "azure", + "bedrock", + # Providers dispatched to BaseLLMHTTPHandler.completion (shared httpx handler) + "a2a", + "anthropic_text", + "bedrock_mantle", + "bytez", + "cloudflare", + "cohere", + "cohere_chat", + "cometapi", + "compactifai", + "databricks", + "databricks_agent", + "datarobot", + "deepseek", + "edenai", + "fal_ai", + "fireworks_ai", + "gdc", + "gigachat", + "gradient_ai", + "groq", + "heroku", + "hosted_vllm", + "huggingface", + "langflow", + "langgraph", + "lemonade", + "minimax", + "mistral", + "nadir", + "oci", + "ollama", + "ollama_chat", + "openrouter", + "ovhcloud", + "ragflow", + "scaledown", + "snowflake", + "text-completion-codestral", + "together_ai", + "triton", + "vercel_ai_gateway", + "watsonx_text", + "xai", + ] if custom_llm_provider in supported_providers: return True - return False + return Falsereturn False def supports_system_messages(model: str, custom_llm_provider: str | None) -> bool: From 802d21a4e795e8bf9d19df815672f52a34daa0c8 Mon Sep 17 00:00:00 2001 From: Anish Gurjar <50738829+anishgurjar@users.noreply.github.com> Date: Wed, 21 Oct 2026 17:53:04 -0400 Subject: [PATCH 3/3] Update utils.py --- litellm/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/litellm/utils.py b/litellm/utils.py index 6bd0f905dc5..75ee4c080d0 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -2914,7 +2914,7 @@ def supports_httpx_timeout(custom_llm_provider: str) -> bool: if custom_llm_provider in supported_providers: return True - return Falsereturn False + return False def supports_system_messages(model: str, custom_llm_provider: str | None) -> bool: