From d6949e53234d1b07aa56be5d2ec1bd6d868254a3 Mon Sep 17 00:00:00 2001 From: Julio Quinteros Pro Date: Wed, 4 Mar 2026 11:16:48 -0300 Subject: [PATCH] Fix A2A message context_id access when message is a dict The asend_message function accessed request.params.message.context_id using attribute syntax, but message can be either a dict or an object. Handle both cases using isinstance check, matching the existing pattern in litellm/a2a_protocol/utils.py. Co-Authored-By: Claude Opus 4.6 --- litellm/a2a_protocol/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/litellm/a2a_protocol/main.py b/litellm/a2a_protocol/main.py index 401b602fef5..485b57e311b 100644 --- a/litellm/a2a_protocol/main.py +++ b/litellm/a2a_protocol/main.py @@ -271,8 +271,13 @@ async def asend_message( card_url = getattr(agent_card, "url", None) if agent_card else None context_id = trace_id or str(uuid.uuid4()) - if request.params.message.context_id is None: - request.params.message.context_id = context_id + message = request.params.message + if isinstance(message, dict): + if message.get("context_id") is None: + message["context_id"] = context_id + else: + if getattr(message, "context_id", None) is None: + message.context_id = context_id # Retry loop: if connection fails due to localhost URL in agent card, retry with fixed URL a2a_response = None