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(router): handle tools=None in filter_web_search_deployments (#17684)

Cesar Garcia7c2e2111c0cc
diff --git a/litellm/router_utils/common_utils.py b/litellm/router_utils/common_utils.py
index 15725e30d04..10acc343abd 100644
--- a/litellm/router_utils/common_utils.py
+++ b/litellm/router_utils/common_utils.py
@@ -110,7 +110,7 @@ def filter_web_search_deployments(
return healthy_deployments
is_web_search_request = False
- tools = request_kwargs.get("tools", [])
+ tools = request_kwargs.get("tools") or []
for tool in tools:
# These are the two websearch tools for OpenAI / Azure.
if tool.get("type") == "web_search" or tool.get("type") == "web_search_preview":
diff --git a/tests/test_litellm/router_utils/test_router_utils_common_utils.py b/tests/test_litellm/router_utils/test_router_utils_common_utils.py
index f73609d47ba..8ff1ba45cc2 100644
--- a/tests/test_litellm/router_utils/test_router_utils_common_utils.py
+++ b/tests/test_litellm/router_utils/test_router_utils_common_utils.py
@@ -248,6 +248,11 @@ class TestFilterWebSearchDeployments:
result = filter_web_search_deployments(sample_deployments, {"tools": []})
assert result == sample_deployments
+ def test_none_tools_returns_all(self, sample_deployments):
+ """When tools is explicitly None, return all deployments (regression test for #17672)"""
+ result = filter_web_search_deployments(sample_deployments, {"tools": None})
+ assert result == sample_deployments
+
def test_non_web_search_tools_returns_all(self, sample_deployments):
"""When tools don't include web_search, return all deployments"""
request_kwargs = {"tools": [{"type": "function", "function": {}}]}