fix: Import A2A well known path from A2A sdk

PiperOrigin-RevId: 783036797
This commit is contained in:
Holt Skinner
2025-07-14 14:10:23 -07:00
committed by Copybara-Service
parent a4baa35b84
commit a6716a5514
6 changed files with 26 additions and 8 deletions
+2 -1
View File
@@ -14,6 +14,7 @@
from google.adk.agents import Agent
from google.adk.agents.remote_a2a_agent import AGENT_CARD_WELL_KNOWN_PATH
from google.adk.agents.remote_a2a_agent import RemoteA2aAgent
from google.adk.tools.langchain_tool import LangchainTool
from langchain_community.tools import YouTubeSearchTool
@@ -41,7 +42,7 @@ bigquery_agent = RemoteA2aAgent(
name="bigquery_agent",
description="Help customer to manage notion workspace.",
agent_card=(
"http://localhost:8001/a2a/bigquery_agent/.well-known/agent.json"
f"http://localhost:8001/a2a/bigquery_agent{AGENT_CARD_WELL_KNOWN_PATH}"
),
)
+2 -1
View File
@@ -15,6 +15,7 @@
import random
from google.adk.agents import Agent
from google.adk.agents.remote_a2a_agent import AGENT_CARD_WELL_KNOWN_PATH
from google.adk.agents.remote_a2a_agent import RemoteA2aAgent
from google.adk.tools.example_tool import ExampleTool
from google.genai import types
@@ -87,7 +88,7 @@ prime_agent = RemoteA2aAgent(
name="prime_agent",
description="Agent that handles checking if numbers are prime.",
agent_card=(
"http://localhost:8001/a2a/check_prime_agent/.well-known/agent.json"
f"http://localhost:8001/a2a/check_prime_agent{AGENT_CARD_WELL_KNOWN_PATH}"
),
)
@@ -14,6 +14,7 @@
from google.adk import Agent
from google.adk.agents.remote_a2a_agent import AGENT_CARD_WELL_KNOWN_PATH
from google.adk.agents.remote_a2a_agent import RemoteA2aAgent
from google.genai import types
@@ -28,7 +29,9 @@ def reimburse(purpose: str, amount: float) -> str:
approval_agent = RemoteA2aAgent(
name='approval_agent',
description='Help approve the reimburse if the amount is greater than 100.',
agent_card='http://localhost:8001/a2a/human_in_loop/.well-known/agent.json',
agent_card=(
f'http://localhost:8001/a2a/human_in_loop{AGENT_CARD_WELL_KNOWN_PATH}'
),
)
+1 -1
View File
@@ -80,7 +80,7 @@ dev = [
a2a = [
# go/keep-sorted start
"a2a-sdk>=0.2.7;python_version>='3.10'"
"a2a-sdk>=0.2.11;python_version>='3.10'"
# go/keep-sorted end
]
+15 -3
View File
@@ -26,7 +26,7 @@ import uuid
try:
from a2a.client import A2AClient
from a2a.client.client import A2ACardResolver # Import A2ACardResolver
from a2a.client.client import A2ACardResolver
from a2a.types import AgentCard
from a2a.types import Message as A2AMessage
from a2a.types import MessageSendParams as A2AMessageSendParams
@@ -35,7 +35,6 @@ try:
from a2a.types import SendMessageRequest
from a2a.types import SendMessageSuccessResponse
from a2a.types import Task as A2ATask
except ImportError as e:
import sys
@@ -46,6 +45,12 @@ except ImportError as e:
else:
raise e
try:
from a2a.utils.constants import AGENT_CARD_WELL_KNOWN_PATH
except ImportError:
# Fallback for older versions of a2a-sdk.
AGENT_CARD_WELL_KNOWN_PATH = "/.well-known/agent.json"
from google.genai import types as genai_types
import httpx
@@ -63,11 +68,18 @@ from ..flows.llm_flows.functions import find_matching_function_call
from ..utils.feature_decorator import experimental
from .base_agent import BaseAgent
__all__ = [
"A2AClientError",
"AGENT_CARD_WELL_KNOWN_PATH",
"AgentCardResolutionError",
"RemoteA2aAgent",
]
# Constants
A2A_METADATA_PREFIX = "a2a:"
DEFAULT_TIMEOUT = 600.0
logger = logging.getLogger("google_adk." + __name__)
+2 -1
View File
@@ -1003,6 +1003,7 @@ def get_fast_api_app(
from a2a.server.request_handlers import DefaultRequestHandler
from a2a.server.tasks import InMemoryTaskStore
from a2a.types import AgentCard
from a2a.utils.constants import AGENT_CARD_WELL_KNOWN_PATH
from ..a2a.executor.a2a_agent_executor import A2aAgentExecutor
@@ -1066,7 +1067,7 @@ def get_fast_api_app(
routes = a2a_app.routes(
rpc_url=f"/a2a/{app_name}",
agent_card_url=f"/a2a/{app_name}/.well-known/agent.json",
agent_card_url=f"/a2a/{app_name}{AGENT_CARD_WELL_KNOWN_PATH}",
)
for new_route in routes: