From 0d689e97116372679e198a77ee0fd5afaec11f3b Mon Sep 17 00:00:00 2001 From: Julio Quinteros Date: Thu, 5 Mar 2026 06:38:54 -0300 Subject: [PATCH] fix(a2a): replace bare assert with descriptive RuntimeError on retry exhaustion If both retry attempts in asend_message absorb A2ALocalhostURLError silently, the bare assert would fire as AssertionError with no context. Replace with a RuntimeError that includes the request_id for easier debugging. Co-Authored-By: Claude Sonnet 4.6 --- litellm/a2a_protocol/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/litellm/a2a_protocol/main.py b/litellm/a2a_protocol/main.py index 485b57e311b..9a4ffdc6af3 100644 --- a/litellm/a2a_protocol/main.py +++ b/litellm/a2a_protocol/main.py @@ -314,8 +314,11 @@ async def asend_message( verbose_logger.info(f"A2A send_message completed, request_id={request.id}") - # a2a_response is guaranteed to be set if we reach here (loop breaks on success or raises) - assert a2a_response is not None + if a2a_response is None: + raise RuntimeError( + "A2A send_message failed: no response received after retry attempts. " + f"request_id={request.id}" + ) # Wrap in LiteLLM response type for _hidden_params support response = LiteLLMSendMessageResponse.from_a2a_response(a2a_response)