{"record":{"id":"b47c556bb64935c6","repo":"BerriAI/litellm","slug":"cannot-retry-a2a-localhost-url-fix-no-agent-card","errorCode":null,"errorMessage":"Cannot retry A2A localhost URL fix: no agent card is available to rewrite, so the upstream URL cannot be corrected.","messagePattern":"Cannot retry A2A localhost URL fix: no agent card is available to rewrite, so the upstream URL cannot be corrected\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/a2a_protocol/exception_mapping_utils.py","lineNumber":188,"sourceCode":"    with the corrected URL.\n\n    Args:\n        error: The localhost URL error\n        agent_card: The agent card object to fix\n        a2a_client: The current A2A client\n        is_streaming: Whether this is a streaming request (for logging)\n\n    Returns:\n        A new A2A client with the fixed URL\n\n    Raises:\n        ImportError: If the A2A SDK is not installed\n    \"\"\"\n    if not A2A_SDK_AVAILABLE:\n        raise ImportError(\"A2A SDK is required for localhost retry handling. Install it with: pip install a2a-sdk\")\n\n    if agent_card is None:\n        raise RuntimeError(\n            \"Cannot retry A2A localhost URL fix: no agent card is available to \"\n            \"rewrite, so the upstream URL cannot be corrected.\"\n        )\n\n    request_type: Final = \"streaming \" if is_streaming else \"\"\n    verbose_logger.warning(\n        \"A2A %srequest to '%s' failed: %s. Agent card contains localhost/internal URL. Retrying with base_url '%s'.\",\n        request_type,\n        error.localhost_url,\n        error.original_error,\n        error.base_url,\n    )\n\n    # Fix the agent card URL\n    set_agent_card_url(agent_card, error.base_url)\n\n    # Reuse the httpx client and call context LiteLLM attached at creation, since the\n    # context carries this agent's trace-id/auth headers. Only clients built by","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/a2a_protocol/exception_mapping_utils.py#L170-L206","documentation":"Error \"Cannot retry A2A localhost URL fix: no agent card is available to rewrite, so the upstream URL cannot be corrected.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/a2a_protocol/exception_mapping_utils.py:188 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fetch the agent card first (or create the client via create_a2a_client) so the localhost URL can be rewritten before retrying."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}