fix(router): handle tools=None in filter_web_search_deployments (#17684)

Fixes #17672

Changed `request_kwargs.get("tools", [])` to `request_kwargs.get("tools") or []`
to handle the case where tools is explicitly set to None.
This commit is contained in:
Cesar Garcia 2025-12-08 23:36:46 -03:00 • committed by GitHub
parent a904067d38
commit 7c2e2111c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -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":

View file

@ -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": {}}]}