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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(websearch): address Responses review findings
Krrish Dholakia7f598c6a9bc4
diff --git a/litellm/integrations/websearch_interception/handler.py b/litellm/integrations/websearch_interception/handler.pyindex 5cdfe03103b..21d990e8e60 100644--- a/litellm/integrations/websearch_interception/handler.py+++ b/litellm/integrations/websearch_interception/handler.py@@ -985,7 +985,14 @@ class WebSearchInterceptionLogger(CustomLogger):k: vfor k, v in kwargs.items()if not k.startswith("_websearch_interception")- and k not in {"litellm_logging_obj", "acompletion", "custom_llm_provider", "model_alias_map"}+ and k+ not in {+ "_agentic_loop_api_surface",+ "litellm_logging_obj",+ "acompletion",+ "custom_llm_provider",+ "model_alias_map",+ }}full_model_name = modeldiff --git a/litellm/integrations/websearch_interception/transformation.py b/litellm/integrations/websearch_interception/transformation.pyindex 47240adaf64..282d75d3d4d 100644--- a/litellm/integrations/websearch_interception/transformation.py+++ b/litellm/integrations/websearch_interception/transformation.py@@ -95,10 +95,7 @@ class WebSearchTransformation:call_id = getattr(item, "call_id", None)arguments = getattr(item, "arguments", "")- if item_type != "function_call" or item_name not in (- LITELLM_WEB_SEARCH_TOOL_NAME,- "web_search",- ):+ if item_type != "function_call" or item_name != LITELLM_WEB_SEARCH_TOOL_NAME:continueif isinstance(arguments, str):diff --git a/tests/test_litellm/integrations/websearch_interception/test_websearch_responses.py b/tests/test_litellm/integrations/websearch_interception/test_websearch_responses.pyindex 519aaa108c9..00b7299cc31 100644--- a/tests/test_litellm/integrations/websearch_interception/test_websearch_responses.py+++ b/tests/test_litellm/integrations/websearch_interception/test_websearch_responses.py@@ -15,7 +15,6 @@ from litellm.integrations.websearch_interception.handler import (WebSearchInterceptionLogger,)from litellm.types.integrations.custom_logger import (- CHAT_COMPLETION_AGENTIC_SURFACE,RESPONSES_AGENTIC_SURFACE,)from litellm.types.utils import CallTypes, LlmProviders@@ -117,6 +116,27 @@ async def test_responses_hook_ignores_non_websearch_function_call():assert tools_dict == {}+async def test_responses_hook_ignores_bare_web_search_function_call():+ logger = WebSearchInterceptionLogger(enabled_providers=[LlmProviders.OPENAI])+ response = SimpleNamespace(+ output=[SimpleNamespace(type="function_call", name="web_search", call_id="c1", arguments="{}")]+ )++ should_run, tools_dict = await logger.async_should_run_responses_agentic_loop(+ response=response,+ model="gpt-4o",+ messages=[{"role": "user", "content": "hi"}],+ tools=[{"type": "function", "name": "litellm_web_search"}],+ stream=False,+ custom_llm_provider="openai",+ kwargs={},+ )++ assert should_run is False+ assert tools_dict == {}++@pytest.mark.asyncioasync def test_surface_marker_routes_should_run_to_responses_branch():"""async_should_run_agentic_loop must dispatch to the responses branch when the@@ -201,7 +221,10 @@ async def test_build_responses_plan_produces_responses_input():},logging_obj=MagicMock(),stream=False,- kwargs={"custom_llm_provider": "openai"},+ kwargs={+ "custom_llm_provider": "openai",+ "_agentic_loop_api_surface": RESPONSES_AGENTIC_SURFACE,+ },)assert plan.run_agentic_loop is True@@ -225,6 +248,7 @@ async def test_build_responses_plan_produces_responses_input():assert patch_obj.tools == [{"type": "function", "name": "litellm_web_search"}]assert "tool_choice" not in patch_obj.optional_params+ assert "_agentic_loop_api_surface" not in patch_obj.kwargsassert patch_obj.model == "openai/gpt-4o"