feat: Add DNS-AID tools for agent discovery via DNS#4856
feat: Add DNS-AID tools for agent discovery via DNS#4856IngmarVG-IB wants to merge 2 commits intogoogle:mainfrom
Conversation
Add native DNS-AID tools that enable AI agents to discover, publish, and unpublish other agents using DNS SVCB records (IETF draft-mozleywilliams-dnsop-dnsaid-01). DNS-AID provides decentralized agent discovery without centralized registries, using existing DNS infrastructure. Requires: dns-aid>=0.12.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates DNS-AID (DNS-based Agent Identification and Discovery) into the Google ADK framework. It provides a decentralized discovery mechanism for AI agents, allowing ADK to find and interact with agents published via DNS SVCB records, specifically bridging DNS-AID discovered agents to ADK's existing A2A protocol support. This enhances ADK's ability to discover and connect with a broader range of agents. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Hello @IngmarVG-IB, thank you for your contribution! This PR is a new feature, could you please create a GitHub issue and associate it with this PR? In addition, could you please provide the results of the unit tests as mentioned in your testing plan? This information will help reviewers to review your PR more efficiently. Thanks! Response from ADK Triaging Agent |
There was a problem hiding this comment.
Code Review
This pull request introduces DNS-AID tools for agent discovery, publishing, and unpublishing, along with a bridge to make discovered agents compatible with ADK's A2A protocol. The changes are well-structured. I've identified a critical issue in how function wrappers are created, which would prevent the tools from working correctly with the language model. I've also included some suggestions to improve type safety and maintainability.
src/google/adk/tools/dns_aid_tool.py
Outdated
| async def _publish(**kwargs): # type: ignore[no-untyped-def] | ||
| return await publish_agent(backend_name=backend_name, **kwargs) | ||
|
|
||
| async def _unpublish(**kwargs): # type: ignore[no-untyped-def] | ||
| return await unpublish_agent(backend_name=backend_name, **kwargs) |
There was a problem hiding this comment.
The use of **kwargs in the _publish and _unpublish wrapper functions is a critical issue. FunctionTool relies on inspecting the function's signature to generate the tool definition for the language model. With a generic **kwargs signature, the model won't know which arguments to provide, causing tool calls to fail. The wrapper functions must explicitly define all the parameters of the original functions (except for the bound backend_name) to ensure correct introspection.
| async def _publish(**kwargs): # type: ignore[no-untyped-def] | |
| return await publish_agent(backend_name=backend_name, **kwargs) | |
| async def _unpublish(**kwargs): # type: ignore[no-untyped-def] | |
| return await unpublish_agent(backend_name=backend_name, **kwargs) | |
| async def _publish(agent_name: str, domain: str, protocol: str = "mcp", endpoint: str = "", port: int = 443, capabilities: Optional[list[str]] = None, version: str = "1.0.0", description: Optional[str] = None, ttl: int = 3600): | |
| return await publish_agent(backend_name=backend_name, agent_name=agent_name, domain=domain, protocol=protocol, endpoint=endpoint, port=port, capabilities=capabilities, version=version, description=description, ttl=ttl) | |
| async def _unpublish(agent_name: str, domain: str, protocol: str = "mcp"): | |
| return await unpublish_agent(backend_name=backend_name, agent_name=agent_name, domain=domain, protocol=protocol) |
There was a problem hiding this comment.
Fixed in a7adb4c. Both _publish and _unpublish now have explicit parameter signatures matching the original functions (minus backend_name), so FunctionTool can correctly introspect them for LLM tool schemas.
| from typing import Any | ||
|
|
||
|
|
||
| async def a2a_agent_from_record(agent_record: Any) -> dict[str, Any]: |
There was a problem hiding this comment.
Using Any for agent_record reduces type safety. It's better to use the specific AgentRecord type. You'll need to import it from dns_aid.core.models at the top of the file. Using a string forward reference here avoids forcing an import change in this suggestion, but the import should be added.
| async def a2a_agent_from_record(agent_record: Any) -> dict[str, Any]: | |
| async def a2a_agent_from_record(agent_record: "AgentRecord") -> dict[str, Any]: |
There was a problem hiding this comment.
Fixed in a7adb4c. Changed to agent_record: AgentRecord with the import moved to the top of the file.
| Raises: | ||
| ValueError: If the agent record is not using A2A protocol. | ||
| """ | ||
| from dns_aid.core.models import Protocol |
| "capabilities": agent_record.capabilities or [], | ||
| "description": agent_record.description, | ||
| "protocol": "a2a", | ||
| "a2a_card_url": f"{base_url}/.well-known/agent-card.json", |
There was a problem hiding this comment.
Fixed in a7adb4c. Extracted A2A_AGENT_CARD_PATH = "/.well-known/agent-card.json" as a module-level constant.
src/google/adk/tools/dns_aid_tool.py
Outdated
| ) | ||
|
|
||
|
|
||
| def get_dns_aid_tools(backend_name: Optional[str] = None) -> list: |
There was a problem hiding this comment.
The return type hint list is too generic. For better type safety and readability, please specify the type of elements in the list. Since FunctionTool is lazy-loaded in this package, you can use a string forward reference: list["FunctionTool"].
| def get_dns_aid_tools(backend_name: Optional[str] = None) -> list: | |
| def get_dns_aid_tools(backend_name: Optional[str] = None) -> list["FunctionTool"]: |
There was a problem hiding this comment.
Fixed in a7adb4c. Return type is now list["FunctionTool"].
- 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)
|
Thanks for the review @gemini-code-assist and @adk-bot! Fixes Applied (commit a7adb4c)Critical: Type hints — Imports — Moved Magic string — Extracted Will create a GitHub issue and provide unit test results as requested. |
|
Thanks for the update, @IngmarVG-IB! It's great to see these improvements addressing key aspects of code quality and maintainability:
I also note your plan to create a GitHub issue and provide unit test results, which will be very helpful for the review process. Keep up the great work! |
|
Hi @IngmarVG-IB , Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you! |
Resolves #4859
Summary
What is DNS-AID?
DNS-AID (DNS-based Agent Identification and Discovery) is an IETF draft that uses DNS SVCB records to enable AI agents to discover and connect with each other. Agents publish their capabilities, endpoints, and protocols to DNS, and other agents query DNS to find available services.
Test plan