@@ -3680,7 +3680,7 @@ def run_async_side_effect(*args, **kwargs):
36803680 assert mock_session_service .call_count == 2
36813681 mock_runner .assert_called_with (
36823682 agent = mock_agent_instance ,
3683- app_name = "local agent run " ,
3683+ app_name = "local_agent_run " ,
36843684 session_service = mock_session_service .return_value ,
36853685 )
36863686 assert mock_runner .call_count == 2
@@ -3795,6 +3795,10 @@ def run_async_side_effect(*args, **kwargs):
37953795 assert inference_result .candidate_name == "mock_agent"
37963796 assert inference_result .gcs_source is None
37973797
3798+ def test_local_agent_run_default_app_name_is_valid (self ):
3799+ """Default app_name must satisfy ADK 2.x's app name validation regex."""
3800+ assert re .fullmatch (r"[a-zA-Z][a-zA-Z0-9_-]*" , "local_agent_run" )
3801+
37983802 def test_run_inference_with_litellm_string_prompt_format (
37993803 self ,
38003804 mock_api_client_fixture ,
@@ -5850,8 +5854,8 @@ def my_plain_tool(query: str) -> str:
58505854 ]
58515855 mock_from_callable .assert_called_once_with (callable = my_plain_tool )
58525856
5853- def test_load_from_agent_with_none_declaration_falls_back (self ):
5854- """Tests that tools returning None from _get_declaration fall back to from_callable ."""
5857+ def test_load_from_agent_with_none_declaration_is_skipped (self ):
5858+ """Tools whose _get_declaration() returns None are skipped, not introspected ."""
58555859 mock_tool = mock .Mock ()
58565860 mock_tool ._get_declaration = mock .Mock (return_value = None )
58575861 mock_tool .__name__ = "mock_tool"
@@ -5867,19 +5871,38 @@ def test_load_from_agent_with_none_declaration_falls_back(self):
58675871 with mock .patch .object (
58685872 genai_types .FunctionDeclaration , "from_callable_with_api_option"
58695873 ) as mock_from_callable :
5870- mock_callable_declaration = mock .Mock (spec = genai_types .FunctionDeclaration )
5871- mock_from_callable .return_value = mock_callable_declaration
5872-
58735874 agent_info = agentplatform_genai_types .evals .AgentInfo .load_from_agent (
58745875 agent = mock_agent ,
58755876 )
58765877
5877- assert len (agent_info .agents ["mock_agent" ].tools ) == 1
5878- assert agent_info .agents ["mock_agent" ].tools [0 ].function_declarations == [
5879- mock_callable_declaration
5880- ]
5878+ assert agent_info .agents ["mock_agent" ].tools == []
58815879 mock_tool ._get_declaration .assert_called_once ()
5882- mock_from_callable .assert_called_once_with (callable = mock_tool )
5880+ mock_from_callable .assert_not_called ()
5881+
5882+ def test_load_from_agent_none_declaration_skips_get_type_hints (self ):
5883+ """A None-returning native tool must not trigger get_type_hints (NameError repro)."""
5884+
5885+ class _BuiltinTool :
5886+ def _get_declaration (self ):
5887+ return None
5888+
5889+ def run (self , query : "Optional[str]" = None ): # noqa: F821
5890+ return query
5891+
5892+ builtin_tool = _BuiltinTool ()
5893+
5894+ mock_agent = mock .Mock ()
5895+ mock_agent .name = "mock_agent"
5896+ mock_agent .instruction = "mock instruction"
5897+ mock_agent .description = "mock description"
5898+ mock_agent .tools = [builtin_tool ]
5899+ mock_agent .sub_agents = []
5900+
5901+ agent_info = agentplatform_genai_types .evals .AgentInfo .load_from_agent (
5902+ agent = mock_agent ,
5903+ )
5904+
5905+ assert agent_info .agents ["mock_agent" ].tools == []
58835906
58845907
58855908class TestValidateDatasetAgentData :
0 commit comments