BerriAI/litellm · error · AgentCardDiscoveryError

Could not fetch agent card from {base_url} (mode={discovery_

Error message

Could not fetch agent card from {base_url} (mode={discovery_mode.value}). Last error: {last_error}

What it means

Raised when every candidate agent-card path failed (network error, HTTP >=400, or non-JSON body) in the chosen discovery mode; the last error is embedded. The base_url, mode, and final failure identify the unreachable/misbehaving agent endpoint.

Source

Thrown at litellm/proxy/a2a/discovery.py:151

        if response.status_code >= 400:
            last_error = f"{url}: HTTP {response.status_code}"
            verbose_proxy_logger.debug("A2A discovery HTTP %s for %s", response.status_code, url)
            continue

        try:
            card = response.json()
        except Exception as exc:
            last_error = f"{url}: invalid JSON ({exc})"
            continue

        if not isinstance(card, dict):
            last_error = f"{url}: expected JSON object, got {type(card).__name__}"
            continue

        verbose_proxy_logger.debug("A2A discovery succeeded at %s", url)
        return card

    raise AgentCardDiscoveryError(
        f"Could not fetch agent card from {base_url} (mode={discovery_mode.value}). Last error: {last_error}"
    )

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check the base_url serves an agent card and is reachable; see last_error detail.

Example fix

curl <base_url>/.well-known/agent.json
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/a2a/discovery.py:151 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/58fa74f1d90f12b8. Report an issue: GitHub.