From 84dd6d8d47d22ae12ca6a80c42cbcc1a45ab42bb Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 7 Mar 2026 06:03:38 +0000 Subject: [PATCH] fix: use cache-key-only param for A2A extra_headers to avoid AsyncHTTPHandler init error The 'extra_headers' key in params was being passed to AsyncHTTPHandler.__init__() which doesn't accept it. Use 'disable_aiohttp_transport' as the cache-key-only param since it's explicitly filtered out before reaching the constructor. Co-authored-by: Ishaan Jaff --- litellm/a2a_protocol/main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/litellm/a2a_protocol/main.py b/litellm/a2a_protocol/main.py index ea22b200566..8cf477ee5e1 100644 --- a/litellm/a2a_protocol/main.py +++ b/litellm/a2a_protocol/main.py @@ -656,11 +656,17 @@ async def create_a2a_client( # (with different extra_headers) get separate cached clients. The params # dict is hashed into the cache key, keeping agent auth isolated while # still reusing connections within the same agent. + # + # Only pass params that AsyncHTTPHandler.__init__ accepts (e.g. timeout). + # Use "disable_aiohttp_transport" key for cache-key-only data (it's + # filtered out before reaching the constructor). _client_params: dict = {"timeout": timeout} if extra_headers: - # Include sorted header keys in params so each unique header set - # produces a distinct cache key. - _client_params["extra_headers"] = str(sorted(extra_headers.items())) + # Encode headers into a cache-key-only param so each unique header + # set produces a distinct cache key. + _client_params["disable_aiohttp_transport"] = str( + sorted(extra_headers.items()) + ) _async_handler = get_async_httpx_client( llm_provider=httpxSpecialProvider.A2AProvider, params=_client_params,