2626from google .adk .models .registry import LLMRegistry
2727from google .adk .sessions .in_memory_session_service import InMemorySessionService
2828from google .adk .tools .google_search_tool import google_search
29+ from google .adk .tools .google_search_tool import GoogleSearchTool
2930from google .adk .tools .vertex_ai_search_tool import VertexAiSearchTool
3031from google .genai import types
3132from pydantic import BaseModel
@@ -310,6 +311,25 @@ async def test_handle_google_search_with_other_tools(self):
310311 assert tools [1 ].name == 'google_search_agent'
311312 assert tools [1 ].__class__ .__name__ == 'GoogleSearchAgentTool'
312313
314+ async def test_handle_google_search_with_other_tools_no_bypass (self ):
315+ """Test that google_search is not wrapped into an agent."""
316+ agent = LlmAgent (
317+ name = 'test_agent' ,
318+ model = 'gemini-pro' ,
319+ tools = [
320+ self ._my_tool ,
321+ GoogleSearchTool (bypass_multi_tools_limit = False ),
322+ ],
323+ )
324+ ctx = await _create_readonly_context (agent )
325+ tools = await agent .canonical_tools (ctx )
326+
327+ assert len (tools ) == 2
328+ assert tools [0 ].name == '_my_tool'
329+ assert tools [0 ].__class__ .__name__ == 'FunctionTool'
330+ assert tools [1 ].name == 'google_search'
331+ assert tools [1 ].__class__ .__name__ == 'GoogleSearchTool'
332+
313333 async def test_handle_google_search_only (self ):
314334 """Test that google_search is not wrapped into an agent."""
315335 agent = LlmAgent (
@@ -346,8 +366,8 @@ async def test_function_tool_only(self):
346366 'google.auth.default' ,
347367 mock .MagicMock (return_value = ('credentials' , 'project' )),
348368 )
349- async def test_handle_google_vais_with_other_tools (self ):
350- """Test that VertexAiSearchTool is wrapped into an agent ."""
369+ async def test_handle_vais_with_other_tools (self ):
370+ """Test that VertexAiSearchTool is replaced with Discovery Engine Search ."""
351371 agent = LlmAgent (
352372 name = 'test_agent' ,
353373 model = 'gemini-pro' ,
@@ -365,6 +385,28 @@ async def test_handle_google_vais_with_other_tools(self):
365385 assert tools [1 ].name == 'discovery_engine_search'
366386 assert tools [1 ].__class__ .__name__ == 'DiscoveryEngineSearchTool'
367387
388+ async def test_handle_vais_with_other_tools_no_bypass (self ):
389+ """Test that VertexAiSearchTool is not replaced."""
390+ agent = LlmAgent (
391+ name = 'test_agent' ,
392+ model = 'gemini-pro' ,
393+ tools = [
394+ self ._my_tool ,
395+ VertexAiSearchTool (
396+ data_store_id = 'test_data_store_id' ,
397+ bypass_multi_tools_limit = False ,
398+ ),
399+ ],
400+ )
401+ ctx = await _create_readonly_context (agent )
402+ tools = await agent .canonical_tools (ctx )
403+
404+ assert len (tools ) == 2
405+ assert tools [0 ].name == '_my_tool'
406+ assert tools [0 ].__class__ .__name__ == 'FunctionTool'
407+ assert tools [1 ].name == 'vertex_ai_search'
408+ assert tools [1 ].__class__ .__name__ == 'VertexAiSearchTool'
409+
368410 async def test_handle_vais_only (self ):
369411 """Test that VertexAiSearchTool is not wrapped into an agent."""
370412 agent = LlmAgent (
0 commit comments