@@ -5836,15 +5836,11 @@ def test_agent_info_creation(self):
58365836 assert agent_info .agents ["agent1" ].description == "description1"
58375837 assert agent_info .agents ["agent1" ].tools == [tool ]
58385838
5839- @mock .patch .object (genai_types .FunctionDeclaration , "from_callable_with_api_option" )
5840- def test_load_from_agent (self , mock_from_callable ):
5839+ def test_load_from_agent (self ):
58415840 def my_search_tool (query : str ) -> str :
58425841 """Searches for information."""
58435842 return f"search result for { query } "
58445843
5845- mock_function_declaration = mock .Mock (spec = genai_types .FunctionDeclaration )
5846- mock_from_callable .return_value = mock_function_declaration
5847-
58485844 mock_agent = mock .Mock ()
58495845 mock_agent .name = "mock_agent"
58505846 mock_agent .instruction = "mock instruction"
@@ -5861,10 +5857,11 @@ def my_search_tool(query: str) -> str:
58615857 assert agent_info .agents ["mock_agent" ].description == "mock description"
58625858 assert len (agent_info .agents ["mock_agent" ].tools ) == 1
58635859 assert isinstance (agent_info .agents ["mock_agent" ].tools [0 ], genai_types .Tool )
5864- assert agent_info .agents ["mock_agent" ].tools [0 ].function_declarations == [
5865- mock_function_declaration
5866- ]
5867- mock_from_callable .assert_called_once_with (callable = my_search_tool )
5860+ declarations = agent_info .agents ["mock_agent" ].tools [0 ].function_declarations
5861+ assert len (declarations ) == 1
5862+ assert isinstance (declarations [0 ], genai_types .FunctionDeclaration )
5863+ assert declarations [0 ].name == "my_search_tool"
5864+ assert declarations [0 ].description == "Searches for information."
58685865
58695866 def test_load_from_agent_with_get_declaration_tool (self ):
58705867 """Tests that tools with _get_declaration() use it instead of from_callable."""
@@ -5887,13 +5884,12 @@ def test_load_from_agent_with_get_declaration_tool(self):
58875884 assert agent_info .name == "mock_agent"
58885885 assert len (agent_info .agents ["mock_agent" ].tools ) == 1
58895886 assert isinstance (agent_info .agents ["mock_agent" ].tools [0 ], genai_types .Tool )
5890- assert agent_info .agents ["mock_agent" ].tools [0 ].function_declarations == [
5891- mock_declaration
5892- ]
5887+ declarations = agent_info .agents ["mock_agent" ].tools [0 ].function_declarations
5888+ assert len ( declarations ) == 1
5889+ assert declarations [ 0 ] is mock_declaration
58935890 mock_tool ._get_declaration .assert_called_once ()
58945891
5895- @mock .patch .object (genai_types .FunctionDeclaration , "from_callable_with_api_option" )
5896- def test_load_from_agent_with_mixed_tools (self , mock_from_callable ):
5892+ def test_load_from_agent_with_mixed_tools (self ):
58975893 """Tests agents with both _get_declaration tools and plain callables."""
58985894
58995895 def my_plain_tool (query : str ) -> str :
@@ -5904,9 +5900,6 @@ def my_plain_tool(query: str) -> str:
59045900 mock_adk_tool = mock .Mock ()
59055901 mock_adk_tool ._get_declaration = mock .Mock (return_value = mock_adk_declaration )
59065902
5907- mock_callable_declaration = mock .Mock (spec = genai_types .FunctionDeclaration )
5908- mock_from_callable .return_value = mock_callable_declaration
5909-
59105903 mock_agent = mock .Mock ()
59115904 mock_agent .name = "mock_agent"
59125905 mock_agent .instruction = "mock instruction"
@@ -5920,15 +5913,15 @@ def my_plain_tool(query: str) -> str:
59205913
59215914 assert len (agent_info .agents ["mock_agent" ].tools ) == 2
59225915 # First tool: ADK tool with _get_declaration
5923- assert agent_info .agents ["mock_agent" ].tools [0 ].function_declarations == [
5924- mock_adk_declaration
5925- ]
5916+ adk_declarations = agent_info .agents ["mock_agent" ].tools [0 ].function_declarations
5917+ assert len ( adk_declarations ) == 1
5918+ assert adk_declarations [ 0 ] is mock_adk_declaration
59265919 mock_adk_tool ._get_declaration .assert_called_once ()
5927- # Second tool: plain callable via from_callable_with_api_option
5928- assert agent_info .agents ["mock_agent" ].tools [1 ].function_declarations == [
5929- mock_callable_declaration
5930- ]
5931- mock_from_callable . assert_called_once_with ( callable = my_plain_tool )
5920+ # Second tool: plain callable converted to FunctionDeclaration
5921+ plain_declarations = agent_info .agents ["mock_agent" ].tools [1 ].function_declarations
5922+ assert len ( plain_declarations ) == 1
5923+ assert isinstance ( plain_declarations [ 0 ], genai_types . FunctionDeclaration )
5924+ assert plain_declarations [ 0 ]. name == " my_plain_tool"
59325925
59335926 def test_load_from_agent_with_none_declaration_is_skipped (self ):
59345927 """Tools whose _get_declaration() returns None are skipped, not introspected."""
@@ -5980,15 +5973,11 @@ def run(self, query: "Optional[str]" = None): # noqa: F821
59805973
59815974 assert agent_info .agents ["mock_agent" ].tools == []
59825975
5983- @mock .patch .object (genai_types .FunctionDeclaration , "from_callable_with_api_option" )
5984- def test_load_from_agent_workflow_root_without_tools (self , mock_from_callable ):
5976+ def test_load_from_agent_workflow_root_without_tools (self ):
59855977 def my_search_tool (query : str ) -> str :
59865978 """Searches for information."""
59875979 return f"search result for { query } "
59885980
5989- mock_function_declaration = mock .Mock (spec = genai_types .FunctionDeclaration )
5990- mock_from_callable .return_value = mock_function_declaration
5991-
59925981 leaf_agent = mock .Mock ()
59935982 leaf_agent .name = "leaf"
59945983 leaf_agent .instruction = "do a step"
@@ -6009,9 +5998,10 @@ def my_search_tool(query: str) -> str:
60095998 assert agent_info .root_agent_id == "pipeline"
60105999 assert agent_info .agents ["pipeline" ].tools == []
60116000 assert len (agent_info .agents ["leaf" ].tools ) == 1
6012- assert agent_info .agents ["leaf" ].tools [0 ].function_declarations == [
6013- mock_function_declaration
6014- ]
6001+ declarations = agent_info .agents ["leaf" ].tools [0 ].function_declarations
6002+ assert len (declarations ) == 1
6003+ assert isinstance (declarations [0 ], genai_types .FunctionDeclaration )
6004+ assert declarations [0 ].name == "my_search_tool"
60156005
60166006 def test_load_from_agent_plain_callable_wraps_in_adk_function_tool (self ):
60176007 """Plain callables with ToolContext params are declared via ADK FunctionTool."""
0 commit comments