From 5e7cb898065158626fec3a4afb90cb23a411095c Mon Sep 17 00:00:00 2001 From: Praveena Date: Tue, 4 Aug 2026 16:33:28 +0530 Subject: [PATCH] fix(azure): respect DEFAULT_MAX_RETRIES in initialize_azure_sdk_client When litellm_params does not include max_retries (the common case for deployments configured without explicit retry settings), initialize_azure_sdk_client() previously passed None through the 'if max_retries is not None' guard, resulting in AsyncAzureOpenAI being created without a max_retries argument. The OpenAI SDK then uses its own hardcoded default of 2, ignoring the DEFAULT_MAX_RETRIES env var. Fix: fall back to litellm.constants.DEFAULT_MAX_RETRIES when litellm_params has no max_retries. This ensures the SDK client respects the configured retry count. Steps to reproduce: 1. Set env var DEFAULT_MAX_RETRIES=0 2. Configure a deployment without explicit max_retries in litellm_params 3. Make a request that triggers a timeout 4. Observe: SDK retries (x-stainless-retry-count=1) despite env var=0 Related: https://github.com/BerriAI/litellm/issues/5124 --- litellm/llms/azure/common_utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/litellm/llms/azure/common_utils.py b/litellm/llms/azure/common_utils.py index 6cb7d09cec4..f20cc37572b 100644 --- a/litellm/llms/azure/common_utils.py +++ b/litellm/llms/azure/common_utils.py @@ -582,7 +582,11 @@ class BaseAzureLLM(BaseOpenAILLM): if scope is None: scope = "https://cognitiveservices.azure.com/.default" - max_retries: Final = litellm_params.get("max_retries") + max_retries = litellm_params.get("max_retries") + if max_retries is None: + from litellm.constants import DEFAULT_MAX_RETRIES + + max_retries = DEFAULT_MAX_RETRIES timeout: Final = litellm_params.get("timeout") if not api_key and azure_ad_token_provider is None and tenant_id and client_id and client_secret: verbose_logger.debug("Using Azure AD Token Provider from Entra ID for Azure Auth")