diff --git a/vertexai/_genai/_agent_engines_utils.py b/vertexai/_genai/_agent_engines_utils.py index 1b9fc8ca79..405f9138b1 100644 --- a/vertexai/_genai/_agent_engines_utils.py +++ b/vertexai/_genai/_agent_engines_utils.py @@ -152,6 +152,8 @@ "ag2", "llama-index", "custom", + "a2a", + "a2a-google-adk" ] ) _DEFAULT_ASYNC_METHOD_NAME = "async_query" diff --git a/vertexai/preview/reasoning_engines/templates/a2a.py b/vertexai/preview/reasoning_engines/templates/a2a.py index 724e2af41e..a96533997c 100644 --- a/vertexai/preview/reasoning_engines/templates/a2a.py +++ b/vertexai/preview/reasoning_engines/templates/a2a.py @@ -212,6 +212,28 @@ def __init__( self.rest_handler = None self.task_store = None self.agent_executor = None + self._set_agent_framework() + + def _set_agent_framework(self): + """Best effort detection of the underlying agent framework.""" + self.agent_framework = "a2a" + agent_executor_builder = self._tmpl_attrs.get("agent_executor_builder") + if agent_executor_builder: + try: + from google.adk.a2a.executor.a2a_agent_executor import ( + A2aAgentExecutor as AdkAgentExecutor, + ) + # It's unlikely that the builder does any heavy lifting, so this + # shouldn't throw any exception. + executor = agent_executor_builder( + **self._tmpl_attrs.get("agent_executor_kwargs") + ) + if isinstance(executor, AdkAgentExecutor): # type: ignore + # A2aAgentExecutor presence indicates a Google ADK agent + # since it requires a `google.adk.runners.Runner` to instantiate. + self.agent_framework = "a2a-google-adk" + except Exception: + pass def clone(self) -> "A2aAgent": """Clones the A2A agent."""