From f2f44900824e4a35c722e93e3a87b8f074166c87 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 16 Sep 2026 23:14:52 +0000 Subject: [PATCH] fix(proxy): keep the no-model_list guard to absent reads so model_list: [] still evicts Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm/proxy/proxy_server.py | 2 +- .../test_update_llm_router_resilience.py | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 08f7a013b12..53bb6da90a0 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -6498,7 +6498,7 @@ class ProxyConfig: if (deployment := llm_router.get_deployment(model_id=model_id)) is not None and deployment.model_info.db_model is False ) - if not model_list + if model_list is None else frozenset() ) if kept_config_ids: diff --git a/tests/test_litellm/proxy/test_update_llm_router_resilience.py b/tests/test_litellm/proxy/test_update_llm_router_resilience.py index 1c7370b8fb8..aaa9d144d4e 100644 --- a/tests/test_litellm/proxy/test_update_llm_router_resilience.py +++ b/tests/test_litellm/proxy/test_update_llm_router_resilience.py @@ -383,3 +383,30 @@ class TestDeleteDeploymentKeepsConfigModelsOnEmptyConfigRead: assert "model-a-id" in model_ids assert "model-b-id" not in model_ids assert result == frozenset({"model-a-id"}) + + @pytest.mark.asyncio + async def test_delete_deployment_evicts_config_models_on_explicit_empty_model_list(self, tmp_path): + config_file_path = str(tmp_path / "config.yaml") + (tmp_path / "config.yaml").write_text("model_list: []\n") + + router = self._router( + [ + { + "model_name": "config-model", + "litellm_params": {"model": "gpt-4o-mini"}, + "model_info": {"id": "config-model-1"}, + }, + ] + ) + proxy_config = ProxyConfig() + with ( + patch("litellm.proxy.proxy_server.llm_router", router), # test-quality-ok: reads module global + patch( # test-quality-ok: reads module global + "litellm.proxy.proxy_server.user_config_file_path", + config_file_path, + ), + ): + result = await proxy_config._delete_deployment(db_models=[]) + + assert router.get_model_ids() == [] + assert result == frozenset()