Skip to content

Commit 78f770b

Browse files
zeroasteriskScion Agent
authored andcommitted
fix: remove underscore prefix from tool method names
FunctionTool derives the tool name from the function's __name__. Methods named _search_ards etc. registered as "_search_ards" in the agent, causing "Tool '_search_ards' not found" errors. Renamed all tool methods to their public names (search_ards, search_agents, etc.) so FunctionTool picks up the correct names without needing a post-hoc override.
1 parent d5e7b6b commit 78f770b

2 files changed

Lines changed: 24 additions & 28 deletions

File tree

src/google/adk_community/tools/ardhf/ardhf_toolset.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ async def _do_search(
304304

305305
# -- Tool implementations -----------------------------------------------
306306

307-
async def _search_ards(
307+
async def search_ards(
308308
self,
309309
tool_context: ToolContext,
310310
query: str,
@@ -330,7 +330,7 @@ async def _search_ards(
330330
query, artifact_type=artifact_type, limit=limit
331331
)
332332

333-
async def _search_agents(
333+
async def search_agents(
334334
self,
335335
tool_context: ToolContext,
336336
query: str,
@@ -349,7 +349,7 @@ async def _search_agents(
349349
"""
350350
return await self._do_search(query, artifact_type="a2a", limit=limit)
351351

352-
async def _search_skills(
352+
async def search_skills(
353353
self,
354354
tool_context: ToolContext,
355355
query: str,
@@ -370,7 +370,7 @@ async def _search_skills(
370370
query, artifact_type="skill", limit=limit
371371
)
372372

373-
async def _search_tools(
373+
async def search_tools(
374374
self,
375375
tool_context: ToolContext,
376376
query: str,
@@ -389,7 +389,7 @@ async def _search_tools(
389389
"""
390390
return await self._do_search(query, artifact_type="mcp", limit=limit)
391391

392-
async def _search_spaces(
392+
async def search_spaces(
393393
self,
394394
tool_context: ToolContext,
395395
query: str,
@@ -410,7 +410,7 @@ async def _search_spaces(
410410
query, artifact_type="space", limit=limit
411411
)
412412

413-
async def _get_agent_card(
413+
async def get_agent_card(
414414
self,
415415
tool_context: ToolContext,
416416
url: str,
@@ -448,7 +448,7 @@ async def _get_agent_card(
448448
"content_type": "text/markdown",
449449
}
450450

451-
async def _connect_agent(
451+
async def connect_agent(
452452
self,
453453
tool_context: ToolContext,
454454
agent_card_url: str,
@@ -568,20 +568,16 @@ async def get_tools(
568568
readonly_context: ReadonlyContext | None = None,
569569
) -> list[BaseTool]:
570570
"""Return all search, inspect, and connect tools."""
571-
tool_defs = [
572-
(self._search_ards, "search_ards"),
573-
(self._search_agents, "search_agents"),
574-
(self._search_skills, "search_skills"),
575-
(self._search_tools, "search_tools"),
576-
(self._search_spaces, "search_spaces"),
577-
(self._get_agent_card, "get_agent_card"),
578-
(self._connect_agent, "connect_agent"),
571+
tool_funcs = [
572+
self.search_ards,
573+
self.search_agents,
574+
self.search_skills,
575+
self.search_tools,
576+
self.search_spaces,
577+
self.get_agent_card,
578+
self.connect_agent,
579579
]
580-
tools: list[BaseTool] = []
581-
for func, name in tool_defs:
582-
tool = FunctionTool(func)
583-
tool.name = name
584-
tools.append(tool)
580+
tools: list[BaseTool] = [FunctionTool(func) for func in tool_funcs]
585581

586582
if readonly_context is not None:
587583
tools = [

tests/unittests/tools/ardhf/test_ardhf_toolset.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ async def test_search_agents_delegates_with_a2a_type(self):
179179
) as mock_search:
180180
mock_search.return_value = {"results": []}
181181
mock_context = AsyncMock()
182-
await toolset._search_agents(
182+
await toolset.search_agents(
183183
mock_context, query="test", limit=5
184184
)
185185

@@ -197,7 +197,7 @@ async def test_search_skills_delegates_with_skill_type(self):
197197
) as mock_search:
198198
mock_search.return_value = {"results": []}
199199
mock_context = AsyncMock()
200-
await toolset._search_skills(
200+
await toolset.search_skills(
201201
mock_context, query="test", limit=5
202202
)
203203

@@ -215,7 +215,7 @@ async def test_search_tools_delegates_with_mcp_type(self):
215215
) as mock_search:
216216
mock_search.return_value = {"results": []}
217217
mock_context = AsyncMock()
218-
await toolset._search_tools(
218+
await toolset.search_tools(
219219
mock_context, query="test", limit=5
220220
)
221221

@@ -233,7 +233,7 @@ async def test_search_spaces_delegates_with_space_type(self):
233233
) as mock_search:
234234
mock_search.return_value = {"results": []}
235235
mock_context = AsyncMock()
236-
await toolset._search_spaces(
236+
await toolset.search_spaces(
237237
mock_context, query="test", limit=5
238238
)
239239

@@ -305,7 +305,7 @@ async def test_get_agent_card_rejects_file_url(self):
305305
toolset = AgentFinderToolset()
306306
mock_context = AsyncMock()
307307

308-
result = await toolset._get_agent_card(
308+
result = await toolset.get_agent_card(
309309
mock_context, url="file:///etc/passwd"
310310
)
311311

@@ -318,7 +318,7 @@ async def test_connect_agent_rejects_file_url(self):
318318
toolset = AgentFinderToolset()
319319
mock_context = AsyncMock()
320320

321-
result = await toolset._connect_agent(
321+
result = await toolset.connect_agent(
322322
mock_context,
323323
agent_card_url="ftp://example.com/agent.json",
324324
message="hello",
@@ -342,7 +342,7 @@ async def test_returns_parsed_json_for_json_content(self):
342342
return_value=json_content,
343343
):
344344
mock_context = AsyncMock()
345-
result = await toolset._get_agent_card(
345+
result = await toolset.get_agent_card(
346346
mock_context, url="https://example.com/tool.json"
347347
)
348348

@@ -361,7 +361,7 @@ async def test_returns_markdown_for_non_json_content(self):
361361
return_value=md_content,
362362
):
363363
mock_context = AsyncMock()
364-
result = await toolset._get_agent_card(
364+
result = await toolset.get_agent_card(
365365
mock_context,
366366
url="https://example.com/SKILL.md",
367367
)

0 commit comments

Comments
 (0)