Skip to content

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]

fix(proxy): keep the no-model_list guard to absent reads so model_list: [] still evicts

Devin AIf2f44900824e
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()