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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(a2a): narrow discovery status codes through a structural protocol
mateo-berri44fff9297dfe
diff --git a/litellm/a2a_protocol/card_resolver.py b/litellm/a2a_protocol/card_resolver.pyindex 9ef73f6293e..8614c794ac4 100644--- a/litellm/a2a_protocol/card_resolver.py+++ b/litellm/a2a_protocol/card_resolver.py@@ -6,7 +6,7 @@ Extends the A2A SDK's card resolver to support multiple well-known paths.from collections.abc import Mappingfrom types import MappingProxyType-from typing import TYPE_CHECKING, Any, Final+from typing import TYPE_CHECKING, Any, Final, Protocol, runtime_checkablefrom litellm._logging import verbose_loggerfrom litellm.a2a_protocol.exceptions import A2AAgentCardDiscoveryError@@ -24,7 +24,6 @@ AGENT_CARD_PATH_PARAM: Final = "agent_card_path"try:from a2a.client import A2ACardResolver as _A2ACardResolver- from a2a.client.errors import AgentCardResolutionErrorfrom a2a.utils.constants import (AGENT_CARD_WELL_KNOWN_PATH,PREV_AGENT_CARD_WELL_KNOWN_PATH,@@ -33,11 +32,16 @@ except ImportError:pass+@runtime_checkable+class _HasStatusCode(Protocol):+ status_code: int | None++def _discovery_status_code(failures: tuple[tuple[str, Exception], ...]) -> int:statuses: Final = tuple(error.status_codefor _, error in failures- if isinstance(error, AgentCardResolutionError) and error.status_code is not None and error.status_code != 404+ if isinstance(error, _HasStatusCode) and error.status_code is not None and error.status_code != 404)return statuses[0] if statuses else 404