Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(e2e): invoke a real published a2a agent and assert it replies

yassin51f0f40c2f34
diff --git a/tests/e2e/a2a/a2a_client.py b/tests/e2e/a2a/a2a_client.py
index c1a1503ec96..07bc2840b2b 100644
--- a/tests/e2e/a2a/a2a_client.py
+++ b/tests/e2e/a2a/a2a_client.py
@@ -11,6 +11,7 @@ here because only this suite uses them.
from __future__ import annotations
+import urllib.request
import warnings
from dataclasses import dataclass
@@ -33,6 +34,11 @@ class A2ASkill(BaseModel):
examples: list[str] | None = None
+class A2AProvider(BaseModel):
+ organization: str
+ url: str
+
+
class AgentCardParams(BaseModel):
"""The upstream agent card an admin registers. `protocolVersion` is the field the
proxy validates against SUPPORTED_A2A_PROTOCOL_VERSIONS on registration."""
@@ -49,6 +55,29 @@ class AgentCardParams(BaseModel):
preferred_transport: str | None = Field(default=None, serialization_alias="preferredTransport")
+class UpstreamAgentCard(BaseModel):
+ """A real published agent card parsed from a public /.well-known endpoint. Keys on
+ the A2A wire aliases so `model_validate_json` reads the served JSON and
+ `model_dump(by_alias=True)` re-emits it unchanged for verbatim registration; it is
+ only ever fetched-and-validated, never hand-constructed, so aliasing on the wire
+ names does not affect any call site."""
+
+ model_config = ConfigDict(populate_by_name=True)
+
+ protocol_version: str = Field(alias="protocolVersion")
+ name: str
+ description: str
+ version: str
+ url: str
+ provider: A2AProvider | None = None
+ documentation_url: str | None = Field(default=None, alias="documentationUrl")
+ capabilities: A2ACapabilities = A2ACapabilities()
+ skills: list[A2ASkill]
+ default_input_modes: list[str] = Field(default=["text"], alias="defaultInputModes")
+ default_output_modes: list[str] = Field(default=["text"], alias="defaultOutputModes")
+ preferred_transport: str | None = Field(default=None, alias="preferredTransport")
+
+
class A2ABridgeParams(BaseModel):
"""litellm_params that route the agent through the completion bridge: an A2A
message/send is transformed into a litellm.acompletion against this provider."""
@@ -61,8 +90,8 @@ class A2ABridgeParams(BaseModel):
class AgentRegisterBody(BaseModel):
agent_name: str
- agent_card_params: AgentCardParams
- litellm_params: A2ABridgeParams
+ agent_card_params: AgentCardParams | UpstreamAgentCard
+ litellm_params: A2ABridgeParams | None = None
class A2ASecurityScheme(BaseModel):
@@ -104,9 +133,32 @@ class A2ATextPart(BaseModel):
text: str
+class A2ASearchPropertiesParams(BaseModel):
+ """The strict param schema of the published property agent's `search_properties`
+ skill (unknown keys are rejected upstream), so a natural-language query like
+ "properties for sale in SF under $2M" is expressed as typed fields."""
+
+ un_locode: str | None = None
+ service_type: str | None = None
+ property_type: str | None = None
+ bedrooms_min: int | None = None
+ asking_price_max: float | None = None
+ limit: int | None = None
+
+
+class A2ASkillInvocation(BaseModel):
+ skill: str
+ params: A2ASearchPropertiesParams
+
+
+class A2ADataPart(BaseModel):
+ kind: str = "data"
+ data: A2ASkillInvocation
+
+
class A2AOutboundMessage(BaseModel):
role: str = "user"
- parts: list[A2ATextPart]
+ parts: list[A2ATextPart | A2ADataPart]
message_id: str = Field(serialization_alias="messageId")
@@ -134,10 +186,16 @@ class A2AResponseMessage(BaseModel):
parts: list[A2AResponsePart] = []
+class A2ATaskStatus(BaseModel):
+ state: str | None = None
+ message: A2AResponseMessage | None = None
+
+
class A2AResult(BaseModel):
"""A message/send result. In 0.3 the message fields sit directly on the result
- (`kind`/`role`/`parts`); in 1.0 they are nested under `message`. `text` reads the
- agent's reply from whichever shape the served version produced."""
+ (`kind`/`role`/`parts`); in 1.0 they are nested under `message`; a real agent that
+ runs a task replies with a `task` whose agent text lives on `status.message`.
+ `text` reads the agent's reply from whichever shape the served version produced."""
model_config = ConfigDict(populate_by_name=True)
@@ -146,10 +204,18 @@ class A2AResult(BaseModel):
message_id: str | None = Field(default=None, alias="messageId")
parts: list[A2AResponsePart] = []
message: A2AResponseMessage | None = None
+ status: A2ATaskStatus | None = None
@property
def text(self) -> str:
- parts = self.message.parts if self.message is not None else self.parts
+ if self.message is not None:
+ parts = self.message.parts
+ elif self.parts:
+ parts = self.parts
+ elif self.status is not None and self.status.message is not None:
+ parts = self.status.message.parts
+ else:
+ parts = []
return "".join(part.text or "" for part in parts)
@property
@@ -218,3 +284,13 @@ class A2AClient:
def build_a2a_client(proxy: ProxyClient) -> A2AClient:
return A2AClient(proxy=proxy)
+
+
+def fetch_agent_card(url: str, *, timeout: float = 20.0) -> UpstreamAgentCard:
+ """Fetch a live A2A agent card from its /.well-known endpoint and parse it into the
+ registration model, so a test can register a real published card verbatim rather
+ than a hand-rolled one."""
+ request = urllib.request.Request(url, headers={"Accept": "application/json"})
+ with urllib.request.urlopen(request, timeout=timeout) as response: # noqa: S310 # pyright: ignore[reportAny] # fixed https well-known url; typeshed types urlopen as Any
+ payload: bytes = response.read() # pyright: ignore[reportAny] # typeshed types urlopen as Any
+ return UpstreamAgentCard.model_validate_json(payload)
diff --git a/tests/e2e/a2a/test_a2a_agent_e2e.py b/tests/e2e/a2a/test_a2a_agent_e2e.py
index 8c19f97e64c..1db7f63ca54 100644
--- a/tests/e2e/a2a/test_a2a_agent_e2e.py
+++ b/tests/e2e/a2a/test_a2a_agent_e2e.py
@@ -14,16 +14,19 @@ import pytest
from a2a_client import (
A2ABridgeParams,
- A2ACapabilities,
A2AClient,
+ A2ADataPart,
A2AJsonRpcRequest,
A2AMessageSendParams,
A2AOutboundMessage,
+ A2ASearchPropertiesParams,
A2ASkill,
+ A2ASkillInvocation,
A2ATextPart,
AgentCardParams,
AgentRegisterBody,
AgentResponse,
+ fetch_agent_card,
)
from e2e_config import unique_marker
from e2e_http import Result, UnknownApiError, unwrap
@@ -31,6 +34,9 @@ from lifecycle import ResourceManager
BRIDGE = A2ABridgeParams(custom_llm_provider="anthropic", model="claude-haiku-4-5")
+MOVEHOME_AGENT_CARD_URL = "https://movehome.org/.well-known/agent.json"
+MOVEHOME_ORIGIN = "https://movehome.org"
+
pytestmark = pytest.mark.e2e
@@ -52,34 +58,6 @@ def _register(client: A2AClient, resources: ResourceManager, protocol_version: s
return agent
-def _google_sdk_default_card(marker: str) -> AgentCardParams:
- """Field-for-field the card the Google a2a-sdk 0.3.x line serves for its helloworld
- sample, whose ``AgentCard`` defaults ``protocolVersion`` to the full semver "0.3.0"
- (the shape the v1.92 regression rejected); ``url`` and ``name`` are the
- deployment-specific fields the SDK requires callers to fill. The url points at a
- reserved example host: a url-bearing card makes message/send dial that upstream
- rather than the completion bridge, so the verbatim-card test asserts registration
- and card serving only."""
- return AgentCardParams(
- protocol_version="0.3.0",
- name=f"E2E A2A sdk {marker}",
- description="Just a hello world agent",
- version="1.0.0",
- url="http://e2e-a2a-upstream.example/",
- capabilities=A2ACapabilities(streaming=True),
- skills=[
- A2ASkill(
- id="hello_world",
- name="Returns hello world",
- description="just returns hello world",
- tags=["hello world"],
- examples=["hi", "hello world"],
- )
- ],
- preferred_transport="JSONRPC",
- )
-
-
def _register_rejection(client: A2AClient, protocol_version: str) -> Result[AgentResponse]:
marker = unique_marker()
body = AgentRegisterBody(
@@ -126,21 +104,35 @@ class TestA2AAgentLifecycle:
assert result is not None
assert result.text != ""
- @pytest.mark.covers("other.a2a.register.sdk_default_card_accepted")
- def test_google_sdk_default_card_registers_verbatim(self, client: A2AClient, resources: ResourceManager, scoped_key: str) -> None:
+ @pytest.mark.covers("other.a2a.message_send.real_world_agent_replies")
+ def test_real_world_agent_replies_to_property_query(self, client: A2AClient, resources: ResourceManager, scoped_key: str) -> None:
+ upstream = fetch_agent_card(MOVEHOME_AGENT_CARD_URL).model_copy(update={"url": MOVEHOME_ORIGIN})
+ assert upstream.protocol_version == "0.3.0"
marker = unique_marker()
- body = AgentRegisterBody(
- agent_name=f"e2e-a2a-sdk-{marker}",
- agent_card_params=_google_sdk_default_card(marker),
- litellm_params=BRIDGE,
- )
+ body = AgentRegisterBody(agent_name=f"e2e-a2a-real-{marker}", agent_card_params=upstream)
agent = unwrap(client.register_agent(body))
resources.defer(lambda: client.delete_agent(agent.agent_id))
assert agent.agent_card_params.protocol_version == "0.3"
- card = unwrap(client.agent_card(agent.agent_id, scoped_key))
- assert card.protocol_version == "0.3"
- assert card.supported_interfaces is not None
- assert card.supported_interfaces[0].protocol_version == "0.3"
+ request = A2AJsonRpcRequest(
+ id=f"e2e-{unique_marker()}",
+ params=A2AMessageSendParams(
+ message=A2AOutboundMessage(
+ parts=[
+ A2ADataPart(
+ data=A2ASkillInvocation(
+ skill="search_properties",
+ params=A2ASearchPropertiesParams(un_locode="USSFO", service_type="sale", asking_price_max=2_000_000, limit=3),
+ )
+ )
+ ],
+ message_id=unique_marker(),
+ )
+ ),
+ )
+ response = unwrap(client.send_message(agent.agent_id, scoped_key, request))
+ assert response.error is None
+ assert response.result is not None
+ assert response.result.text.strip() != ""
@pytest.mark.covers("other.a2a.discovery.proxy_fronted_card")
def test_discovery_card_is_proxy_fronted(self, client: A2AClient, resources: ResourceManager, scoped_key: str) -> None:
diff --git a/tests/e2e/coverage_registry/other.yaml b/tests/e2e/coverage_registry/other.yaml
index 00a76cf511a..ace4f8bcdc9 100644
--- a/tests/e2e/coverage_registry/other.yaml
+++ b/tests/e2e/coverage_registry/other.yaml
@@ -31,7 +31,7 @@
- {id: other.a2a.register.persists, module: other, tier: P1, area: a2a, assertions: [persists], source: "agent_endpoints/endpoints.py:325-443", rationale: "POST /v1/agents registers an agent card; GET /v1/agents/{id} reads it back"}
- {id: other.a2a.register.unsupported_version_rejected, module: other, tier: P1, area: a2a, assertions: [unsupported_version_rejected], source: "agent_endpoints/endpoints.py _validate_protocol_version", rationale: "A card pinning a protocolVersion outside SUPPORTED_A2A_PROTOCOL_VERSIONS is refused with 400"}
- {id: other.a2a.register.semver_version_accepted, module: other, tier: P1, area: a2a, assertions: [semver_version_accepted], source: "agent_endpoints/endpoints.py _validate_protocol_version", rationale: "A card pinning a patch-level semver like 0.3.0 (what the Google A2A SDK emits) registers, stores and serves the canonical 0.3 rather than 400ing; regression guard for the v1.92 report"}
-- {id: other.a2a.register.sdk_default_card_accepted, module: other, tier: P1, area: a2a, assertions: [sdk_default_card_accepted], source: "agent_endpoints/endpoints.py _build_merged_agent_card", rationale: "The full field set the Google a2a-sdk 0.3.x emits (protocolVersion 0.3.0, url, preferredTransport, capabilities, skill examples) registers verbatim and serves the canonical 0.3"}
+- {id: other.a2a.message_send.real_world_agent_replies, module: other, tier: P1, area: a2a, assertions: [real_world_agent_replies], source: "agent_endpoints/a2a_endpoints.py asend_message", rationale: "A real published a2a agent fetched live from a public /.well-known endpoint (pinning the full semver 0.3.0 the a2a-sdk emits) registers, serves the canonical 0.3, and a message/send skill invocation proxies to the live upstream and returns the agent's reply"}
- {id: other.a2a.register.malformed_version_rejected, module: other, tier: P1, area: a2a, assertions: [malformed_version_rejected], source: "a2a/agent_card.py normalize_protocol_version", rationale: "A malformed protocolVersion like 0.3.garbage fails full-string semver validation and is refused with 400 instead of truncating to a supported family"}
- {id: other.a2a.discovery.proxy_fronted_card, module: other, tier: P1, area: a2a, assertions: [proxy_fronted_card], source: "agent_endpoints/a2a_endpoints.py get_agent_card", rationale: "/.well-known/agent-card.json serves the proxy url + supportedInterfaces and the LiteLLM virtual-key bearer scheme, not the upstream"}
- {id: other.a2a.message_send.bridge_invokes, module: other, tier: P1, area: a2a, assertions: [bridge_invokes], source: "a2a_protocol/litellm_completion_bridge/handler.py", rationale: "A2A message/send routes through the completion bridge to a real provider and logs an asend_message spend row"}