{"record":{"id":"7388ac8df0aa10ba","repo":"BerriAI/litellm","slug":"cannot-retry-a2a-localhost-url-fix-the-client-was","errorCode":null,"errorMessage":"Cannot retry A2A localhost URL fix: the client was not created by create_a2a_client, so no LiteLLM httpx client is attached.","messagePattern":"Cannot retry A2A localhost URL fix: the client was not created by create_a2a_client, so no LiteLLM httpx client is attached\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"litellm/a2a_protocol/exception_mapping_utils.py","lineNumber":210,"sourceCode":"\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\n    # ``create_a2a_client`` have them; an externally-supplied client cannot be retried.\n    httpx_client: Final = getattr(a2a_client, \"_litellm_httpx_client\", None)\n    if httpx_client is None:\n        raise RuntimeError(\n            \"Cannot retry A2A localhost URL fix: the client was not created by \"\n            \"create_a2a_client, so no LiteLLM httpx client is attached.\"\n        )\n\n    new_client: Final = await create_client(  # pyright: ignore[reportOptionalCall]\n        agent_card,\n        client_config=ClientConfig(  # pyright: ignore[reportOptionalCall]\n            httpx_client=httpx_client,\n            streaming=is_streaming,\n        ),\n    )\n    new_client._litellm_httpx_client = httpx_client\n    new_client._litellm_call_context = getattr(  # pyright: ignore[reportAttributeAccessIssue]  # LiteLLM-owned stash\n        a2a_client, \"_litellm_call_context\", None\n    )\n    new_client._litellm_agent_card = agent_card\n    return new_client\n","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/a2a_protocol/exception_mapping_utils.py#L192-L228","documentation":"Error \"Cannot retry A2A localhost URL fix: the client was not created by create_a2a_client, so no LiteLLM httpx client is attached.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/a2a_protocol/exception_mapping_utils.py:210 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the A2A client with litellm's create_a2a_client so an httpx client is attached and the localhost retry fix can run."],"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"}