From c6650de5fc3c161eb6597eaf5da86b2a104564eb Mon Sep 17 00:00:00 2001 From: Sarah Wooders Date: Mon, 28 Apr 2025 18:47:29 -0700 Subject: [PATCH] fix: trigger gemini retry with `ValueError` (#1918) --- letta/llm_api/google_ai_client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/letta/llm_api/google_ai_client.py b/letta/llm_api/google_ai_client.py index 36541fb0..5f807f73 100644 --- a/letta/llm_api/google_ai_client.py +++ b/letta/llm_api/google_ai_client.py @@ -122,6 +122,10 @@ class GoogleAIClient(LLMClientBase): for candidate in response_data["candidates"]: content = candidate["content"] + if "role" not in content: + # This means the response is malformed + # NOTE: must be a ValueError to trigger a retry + raise ValueError(f"Error in response data from LLM: {response_data}") role = content["role"] assert role == "model", f"Unknown role in response: {role}"