From 5a1b6fe1a6bdd0ad7d693d3fb0d5b62274a245a4 Mon Sep 17 00:00:00 2001 From: "IQHL (Hans Jacob Landelius)" Date: Wed, 8 Oct 2025 10:55:08 +0200 Subject: [PATCH 1/3] Do not cooldown deployment if exception_status is empty string --- litellm/router_utils/cooldown_handlers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/litellm/router_utils/cooldown_handlers.py b/litellm/router_utils/cooldown_handlers.py index 88bf1c0b27..158c2359bd 100644 --- a/litellm/router_utils/cooldown_handlers.py +++ b/litellm/router_utils/cooldown_handlers.py @@ -62,6 +62,8 @@ def _is_cooldown_required( return False if isinstance(exception_status, str): + if len(exception_status) == 0: + return False exception_status = int(exception_status) if exception_status >= 400 and exception_status < 500: From 5b9d516e435c6af8244be80cad7790de9515495f Mon Sep 17 00:00:00 2001 From: "IQHL (Hans Jacob Landelius)" Date: Wed, 8 Oct 2025 13:58:25 +0200 Subject: [PATCH 2/3] unit test --- .../test_router_cooldown_utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/router_unit_tests/test_router_cooldown_utils.py b/tests/router_unit_tests/test_router_cooldown_utils.py index 19299aa698..2a82b0d091 100644 --- a/tests/router_unit_tests/test_router_cooldown_utils.py +++ b/tests/router_unit_tests/test_router_cooldown_utils.py @@ -18,6 +18,7 @@ from litellm.router_utils.cooldown_handlers import ( _should_run_cooldown_logic, _should_cooldown_deployment, cast_exception_status_to_int, + _is_cooldown_required, ) from litellm.router_utils.router_callbacks.track_deployment_metrics import ( increment_deployment_failures_for_current_minute, @@ -397,3 +398,16 @@ def test_mixed_success_failure(mock_failures, mock_successes, router): assert ( should_cooldown is False ), "Should not cooldown when failure rate is below threshold" + + +def test_is_cooldown_required_empty_string_exception_status(testing_litellm_router): + """ + Test that _is_cooldown_required returns False when exception_status is an empty string + """ + result = _is_cooldown_required( + litellm_router_instance=testing_litellm_router, + model_id="test_deployment", + exception_status="", + ) + + assert result is False, "Should not require cooldown when exception_status is empty string" From 6633b33085940038b3333562b408bbdecd4578c2 Mon Sep 17 00:00:00 2001 From: "IQHL (Hans Jacob Landelius)" Date: Wed, 8 Oct 2025 14:15:15 +0200 Subject: [PATCH 3/3] formatting --- tests/router_unit_tests/test_router_cooldown_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/router_unit_tests/test_router_cooldown_utils.py b/tests/router_unit_tests/test_router_cooldown_utils.py index 2a82b0d091..53edb19de4 100644 --- a/tests/router_unit_tests/test_router_cooldown_utils.py +++ b/tests/router_unit_tests/test_router_cooldown_utils.py @@ -32,6 +32,7 @@ from litellm.router_utils.cooldown_handlers import _should_cooldown_deployment load_dotenv() + @pytest.mark.asyncio async def test_router_cooldown_event_callback_no_deployment(): """ @@ -410,4 +411,6 @@ def test_is_cooldown_required_empty_string_exception_status(testing_litellm_rout exception_status="", ) - assert result is False, "Should not require cooldown when exception_status is empty string" + assert ( + result is False + ), "Should not require cooldown when exception_status is empty string"