From 52674e7fac6b7689f0e3871d41c4523e13471a7e Mon Sep 17 00:00:00 2001 From: Xuan Yang Date: Fri, 21 Nov 2025 15:24:49 -0800 Subject: [PATCH] fix: Update AgentTool to use Agent's description when input_schema is provided in FunctionDeclaration Co-authored-by: Xuan Yang PiperOrigin-RevId: 835379243 --- src/google/adk/tools/agent_tool.py | 2 ++ tests/unittests/tools/test_agent_tool.py | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/google/adk/tools/agent_tool.py b/src/google/adk/tools/agent_tool.py index abfcf369..46d86166 100644 --- a/src/google/adk/tools/agent_tool.py +++ b/src/google/adk/tools/agent_tool.py @@ -79,6 +79,8 @@ class AgentTool(BaseTool): result = _automatic_function_calling_util.build_function_declaration( func=self.agent.input_schema, variant=self._api_variant ) + # Override the description with the agent's description + result.description = self.agent.description else: result = types.FunctionDeclaration( parameters=types.Schema( diff --git a/tests/unittests/tools/test_agent_tool.py b/tests/unittests/tools/test_agent_tool.py index f2bc97b2..a9723b43 100644 --- a/tests/unittests/tools/test_agent_tool.py +++ b/tests/unittests/tools/test_agent_tool.py @@ -679,3 +679,26 @@ def test_include_plugins_false(): # Plugin should only be called for root_agent, not tool_agent assert tracking_plugin.before_agent_calls == 1 + + +def test_agent_tool_description_with_input_schema(): + """Test that agent description is propagated when using input_schema.""" + + class CustomInput(BaseModel): + """This is the Pydantic model docstring.""" + + custom_input: str + + agent_description = 'This is the agent description that should be used' + tool_agent = Agent( + name='tool_agent', + model=testing_utils.MockModel.create(responses=['test response']), + description=agent_description, + input_schema=CustomInput, + ) + + agent_tool = AgentTool(agent=tool_agent) + declaration = agent_tool._get_declaration() + + # The description should come from the agent, not the Pydantic model + assert declaration.description == agent_description