From 35f459851b13e70badf0535b238a9ed967ff2f21 Mon Sep 17 00:00:00 2001 From: A Vertex SDK engineer Date: Mon, 20 Oct 2025 11:19:13 -0700 Subject: [PATCH] feat: add agent_card to agent engine spec PiperOrigin-RevId: 821726573 --- vertexai/_genai/agent_engines.py | 12 ++++++++++++ vertexai/_genai/types/common.py | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/vertexai/_genai/agent_engines.py b/vertexai/_genai/agent_engines.py index 6cfcb8be62..0409b70b92 100644 --- a/vertexai/_genai/agent_engines.py +++ b/vertexai/_genai/agent_engines.py @@ -1229,6 +1229,18 @@ def _create_config( agent=agent, ) ) + + if hasattr(agent, "agent_card"): + agent_card = getattr(agent, "agent_card") + if agent_card: + try: + agent_engine_spec["agent_card"] = agent_card.model_dump( + exclude_none=True + ) + except TypeError as e: + raise ValueError( + f"Failed to convert agent card to dict (serialization error): {e}" + ) from e update_masks.append("spec.agent_framework") if identity_type is not None or service_account is not None: diff --git a/vertexai/_genai/types/common.py b/vertexai/_genai/types/common.py index 03b97aa203..8ba3752e1d 100644 --- a/vertexai/_genai/types/common.py +++ b/vertexai/_genai/types/common.py @@ -4797,6 +4797,10 @@ class ReasoningEngineSpecSourceCodeSpecDict(TypedDict, total=False): class ReasoningEngineSpec(_common.BaseModel): """The specification of an agent engine.""" + agent_card: Optional[dict[str, Any]] = Field( + default=None, + description="""Optional. The A2A Agent Card for the agent (if available). It follows the specification at https://a2a-protocol.org/latest/specification/#5-agent-discovery-the-agent-card.""", + ) agent_framework: Optional[str] = Field( default=None, description="""Optional. The OSS agent framework used to develop the agent. Currently supported values: "google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom".""", @@ -4834,6 +4838,9 @@ class ReasoningEngineSpec(_common.BaseModel): class ReasoningEngineSpecDict(TypedDict, total=False): """The specification of an agent engine.""" + agent_card: Optional[dict[str, Any]] + """Optional. The A2A Agent Card for the agent (if available). It follows the specification at https://a2a-protocol.org/latest/specification/#5-agent-discovery-the-agent-card.""" + agent_framework: Optional[str] """Optional. The OSS agent framework used to develop the agent. Currently supported values: "google-adk", "langchain", "langgraph", "ag2", "llama-index", "custom"."""