Skip to content

Commit f0b8564

Browse files
committed
fix: address Gemini Code Assist review feedback
- Fix critical **kwargs issue in get_dns_aid_tools() wrappers: _publish and _unpublish now have explicit parameter signatures so FunctionTool can introspect them for LLM tool schemas - Add proper type hints: AgentRecord instead of Any, list['FunctionTool'] return type - Move imports to module level in A2A bridge - Extract A2A_AGENT_CARD_PATH constant (no magic strings)
1 parent bee54e2 commit f0b8564

2 files changed

Lines changed: 45 additions & 11 deletions

File tree

src/google/adk/tools/dns_aid_a2a_bridge.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99

1010
from typing import Any
1111

12+
from dns_aid.core.models import AgentRecord, Protocol
1213

13-
async def a2a_agent_from_record(agent_record: Any) -> dict[str, Any]:
14+
# Well-known path for A2A agent cards per the A2A specification.
15+
A2A_AGENT_CARD_PATH = "/.well-known/agent-card.json"
16+
17+
18+
async def a2a_agent_from_record(agent_record: AgentRecord) -> dict[str, Any]:
1419
"""Convert a DNS-AID AgentRecord with A2A protocol to an ADK-compatible reference.
1520
1621
Args:
@@ -22,8 +27,6 @@ async def a2a_agent_from_record(agent_record: Any) -> dict[str, Any]:
2227
Raises:
2328
ValueError: If the agent record is not using A2A protocol.
2429
"""
25-
from dns_aid.core.models import Protocol
26-
2730
if agent_record.protocol != Protocol.A2A:
2831
raise ValueError(
2932
f"Agent {agent_record.name} uses protocol {agent_record.protocol}, not A2A"
@@ -36,5 +39,5 @@ async def a2a_agent_from_record(agent_record: Any) -> dict[str, Any]:
3639
"capabilities": agent_record.capabilities or [],
3740
"description": agent_record.description,
3841
"protocol": "a2a",
39-
"a2a_card_url": f"{base_url}/.well-known/agent-card.json",
42+
"a2a_card_url": f"{base_url}{A2A_AGENT_CARD_PATH}",
4043
}

src/google/adk/tools/dns_aid_tool.py

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ async def unpublish_agent(
117117
)
118118

119119

120-
def get_dns_aid_tools(backend_name: Optional[str] = None) -> list:
120+
def get_dns_aid_tools(backend_name: Optional[str] = None) -> list["FunctionTool"]:
121121
"""Return DNS-AID tools wrapped as Google ADK FunctionTool objects.
122122
123123
Args:
@@ -127,12 +127,43 @@ def get_dns_aid_tools(backend_name: Optional[str] = None) -> list:
127127

128128
tools = [FunctionTool(discover_agents)]
129129
if backend_name:
130-
# Create closures that bind the backend_name
131-
async def _publish(**kwargs): # type: ignore[no-untyped-def]
132-
return await publish_agent(backend_name=backend_name, **kwargs)
133-
134-
async def _unpublish(**kwargs): # type: ignore[no-untyped-def]
135-
return await unpublish_agent(backend_name=backend_name, **kwargs)
130+
# Create closures that bind the backend_name with explicit signatures
131+
# so FunctionTool can introspect parameters for the LLM tool schema.
132+
async def _publish(
133+
agent_name: str,
134+
domain: str,
135+
protocol: str = "mcp",
136+
endpoint: str = "",
137+
port: int = 443,
138+
capabilities: Optional[list[str]] = None,
139+
version: str = "1.0.0",
140+
description: Optional[str] = None,
141+
ttl: int = 3600,
142+
) -> str:
143+
return await publish_agent(
144+
backend_name=backend_name,
145+
agent_name=agent_name,
146+
domain=domain,
147+
protocol=protocol,
148+
endpoint=endpoint,
149+
port=port,
150+
capabilities=capabilities,
151+
version=version,
152+
description=description,
153+
ttl=ttl,
154+
)
155+
156+
async def _unpublish(
157+
agent_name: str,
158+
domain: str,
159+
protocol: str = "mcp",
160+
) -> str:
161+
return await unpublish_agent(
162+
backend_name=backend_name,
163+
agent_name=agent_name,
164+
domain=domain,
165+
protocol=protocol,
166+
)
136167

137168
_publish.__name__ = "publish_agent"
138169
_publish.__doc__ = publish_agent.__doc__

0 commit comments

Comments
 (0)