From 3b94b45cbb88aad6acea0547f23831e1232d90ba Mon Sep 17 00:00:00 2001 From: cthomas Date: Sun, 22 Dec 2024 11:30:01 -0800 Subject: [PATCH] fix: add underlying error message for Retries Exhausted error (#2308) --- letta/agent.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/letta/agent.py b/letta/agent.py index a297f5b6ce..0cbaff6884 100644 --- a/letta/agent.py +++ b/letta/agent.py @@ -282,7 +282,6 @@ def _get_ai_reply( # Force a tool call if exactly one tool is specified elif step_count is not None and step_count > 0 and len(allowed_tool_names) == 1: force_tool_call = allowed_tool_names[0] - for attempt in range(1, empty_response_retry_limit + 1): try: response = create( @@ -314,7 +313,7 @@ def _get_ai_reply( except ValueError as ve: if attempt >= empty_response_retry_limit: warnings.warn(f"Retry limit reached. Final error: {ve}") - break + raise Exception(f"Retries exhausted and no valid response received. Final error: {ve}") else: delay = min(backoff_factor * (2 ** (attempt - 1)), max_delay) warnings.warn(f"Attempt {attempt} failed: {ve}. Retrying in {delay} seconds...")