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]

chore(websearch): justify new mutable annotations for the type-discipline gate

Aidan Sinclair6cc3a6022193
diff --git a/litellm/integrations/websearch_interception/handler.py b/litellm/integrations/websearch_interception/handler.py
index f47751f4762..093e0351c70 100644
--- a/litellm/integrations/websearch_interception/handler.py
+++ b/litellm/integrations/websearch_interception/handler.py
@@ -1523,7 +1523,7 @@ class WebSearchInterceptionLogger(CustomLogger):
objective = tool_input.get("objective")
valid_objective = objective if isinstance(objective, str) and objective.strip() else None
raw_queries = tool_input.get("search_queries")
- valid_queries: list[str] | None = None
+ valid_queries: list[str] | None = None # mutable-ok: matches litellm.asearch's list[str] query parameter
if isinstance(raw_queries, Sequence) and not isinstance(raw_queries, str):
queries = [q for q in raw_queries if isinstance(q, str) and q.strip()]
if queries:
@@ -1619,7 +1619,7 @@ class WebSearchInterceptionLogger(CustomLogger):
# Forward the model's richer shape (objective + keyword queries)
# only to providers whose search API takes it natively; everyone
# else keeps the single query string the model also provided.
- query_arg: str | list[str] = query
+ query_arg: str | list[str] = query # mutable-ok: litellm.asearch declares query as str | list[str]
if rich and self._provider_supports_rich_search(search_provider):
rich_queries = rich.get("search_queries")
if rich_queries:
@@ -1847,7 +1847,7 @@ class WebSearchInterceptionLogger(CustomLogger):
for tool_call in tool_calls:
# Handle both Anthropic-style input and OpenAI-style function.arguments
query = None
- tool_args: dict | None = None
+ tool_args: dict | None = None # mutable-ok: the tool call's own arguments dict
if "input" in tool_call and isinstance(tool_call["input"], dict):
tool_args = tool_call["input"]
query = tool_args.get("query")
diff --git a/litellm/integrations/websearch_interception/tools.py b/litellm/integrations/websearch_interception/tools.py
index 9e3d3fd91f3..2e1ae07eb68 100644
--- a/litellm/integrations/websearch_interception/tools.py
+++ b/litellm/integrations/websearch_interception/tools.py
@@ -17,7 +17,7 @@ _WEB_SEARCH_TOOL_DESCRIPTION: Final = (
)
-def _web_search_input_schema() -> dict[str, object]:
+def _web_search_input_schema() -> dict[str, object]: # mutable-ok: plain-dict tool shape, as the get_* builders
"""
JSON schema for the web search tool's input, shared by every tool format.
diff --git a/litellm/types/integrations/websearch_interception.py b/litellm/types/integrations/websearch_interception.py
index 6b5b1519874..ea5e6d51749 100644
--- a/litellm/types/integrations/websearch_interception.py
+++ b/litellm/types/integrations/websearch_interception.py
@@ -39,7 +39,7 @@ class RichWebSearchInput(TypedDict, total=False):
objective: ReadOnly[str]
"""Natural-language description of the goal behind the search."""
- search_queries: ReadOnly[list[str]]
+ search_queries: ReadOnly[list[str]] # mutable-ok: forwarded verbatim as litellm.asearch's list[str] query argument
"""Two to five short keyword queries covering different angles."""