The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(proxy): only schedule the deprecation loop when alerting is configured
mateo2fe152a1d268
diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.pyindex 1d6d1e69ca4..47eea9218f0 100644--- a/litellm/proxy/utils.py+++ b/litellm/proxy/utils.py@@ -482,7 +482,11 @@ class ProxyLogging:) # RUN HANGING REQUEST CHECK (if user wants to alert on hanging requests)self.hanging_requests_check_started = True- if self.slack_alerting_instance is not None and not self.deprecation_check_started:+ if (+ self.alerting is not None+ and self.slack_alerting_instance is not None+ and not self.deprecation_check_started+ ):asyncio.create_task(self.slack_alerting_instance._run_scheduled_deprecation_check())self.deprecation_check_started = Truediff --git a/tests/test_litellm/proxy/utils/proxy_logging/test_lifecycle.py b/tests/test_litellm/proxy/utils/proxy_logging/test_lifecycle.pyindex cf906259246..b2aa16e88d9 100644--- a/tests/test_litellm/proxy/utils/proxy_logging/test_lifecycle.py+++ b/tests/test_litellm/proxy/utils/proxy_logging/test_lifecycle.py@@ -129,6 +129,21 @@ def test_startup_event_initializes_slack_and_callbacks(proxy_logging):}+async def test_startup_event_schedules_deprecation_check_before_its_alert_type_is_on(proxy_logging):+ """Alerting config can enable the deprecation alert after startup, so the loop must already be running"""+ proxy_logging.alerting = ["slack"]+ proxy_logging.slack_alerting_instance = MagicMock()+ proxy_logging.slack_alerting_instance.alert_types = []+ proxy_logging.slack_alerting_instance._run_scheduled_deprecation_check = AsyncMock()+ proxy_logging._init_litellm_callbacks = MagicMock()++ proxy_logging.startup_event(llm_router=None, redis_usage_cache=None)++ assert proxy_logging.deprecation_check_started is True+ proxy_logging.slack_alerting_instance._run_scheduled_deprecation_check.assert_called_once_with()++def test_startup_event_propagates_init_callbacks_failure_raises(proxy_logging):proxy_logging.slack_alerting_instance = MagicMock()proxy_logging.slack_alerting_instance.alert_types = []