From d903056a43c3fe162f38836c1306d33bd633ab20 Mon Sep 17 00:00:00 2001 From: cthomas Date: Thu, 20 Nov 2025 13:29:38 -0800 Subject: [PATCH] fix: list indices must be int not str error [LET-6254] (#6302) fix: list indices must be int not str error --- letta/llm_api/google_vertex_client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/letta/llm_api/google_vertex_client.py b/letta/llm_api/google_vertex_client.py index aa2e99ba..70a6704d 100644 --- a/letta/llm_api/google_vertex_client.py +++ b/letta/llm_api/google_vertex_client.py @@ -520,6 +520,8 @@ class GoogleVertexClient(LLMClientBase): try: # Structured output tool call function_call = json_loads(response_message.text) + + # Access dict keys - will raise TypeError/KeyError if not a dict or missing keys function_name = function_call["name"] function_args = function_call["args"] assert isinstance(function_args, dict), function_args @@ -557,9 +559,13 @@ class GoogleVertexClient(LLMClientBase): openai_response_message.tool_calls = [] openai_response_message.tool_calls.append(tool_call) - except json.decoder.JSONDecodeError: + except (json.decoder.JSONDecodeError, ValueError, TypeError, KeyError, AssertionError) as e: if candidate.finish_reason == "MAX_TOKENS": raise LLMServerError("Could not parse response data from LLM: exceeded max token limit") + # Log the parsing error for debugging + logger.warning( + f"Failed to parse structured output from LLM response: {e}. Response text: {response_message.text[:500]}" + ) # Inner thoughts are the content by default inner_thoughts = response_message.text