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]

refactor(a2a): use direct typed access in protocol binding normalization

milan0697188be40c
diff --git a/litellm/a2a_protocol/card_resolver.py b/litellm/a2a_protocol/card_resolver.py
index 8070d88b761..47d6346b9a6 100644
--- a/litellm/a2a_protocol/card_resolver.py
+++ b/litellm/a2a_protocol/card_resolver.py
@@ -67,11 +67,9 @@ def normalize_agent_card_protocol_bindings(agent_card: "AgentCard") -> "AgentCar
case-sensitively against its uppercase TransportProtocol constants and fails
with "no compatible transports found." for spec-adjacent casings.
"""
- interfaces: Final = getattr(agent_card, "supported_interfaces", None) or ()
- for interface in interfaces:
- binding: str = getattr(interface, "protocol_binding", "") or ""
- canonical = _CANONICAL_PROTOCOL_BINDINGS.get(binding.lower())
- if canonical is not None and binding != canonical:
+ for interface in agent_card.supported_interfaces:
+ canonical: str | None = _CANONICAL_PROTOCOL_BINDINGS.get(interface.protocol_binding.lower())
+ if canonical is not None and canonical != interface.protocol_binding:
interface.protocol_binding = canonical
return agent_card
diff --git a/tests/test_litellm/a2a_protocol/test_main.py b/tests/test_litellm/a2a_protocol/test_main.py
index 29aa3aaabd7..aa988bc5b99 100644
--- a/tests/test_litellm/a2a_protocol/test_main.py
+++ b/tests/test_litellm/a2a_protocol/test_main.py
@@ -344,6 +344,7 @@ async def test_lowercase_protocol_binding_in_agent_card_still_gets_a_client(isol
response = await _send_message(a2a_client, _send_request("lc"))
assert type(response.root.result).__name__ == "Message"
+ assert a2a_client._litellm_agent_card.supported_interfaces[0].protocol_binding == "JSONRPC"
@pytest.mark.asyncio