From 731e314b5d4bf528beff905472c7b1b8058439c4 Mon Sep 17 00:00:00 2001 From: cthomas Date: Mon, 13 Oct 2025 16:14:19 -0700 Subject: [PATCH] fix: anthropic payload tool parse error LET-5469 (#5388) fix: anthropic payload tool parse error --- letta/llm_api/anthropic_client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/letta/llm_api/anthropic_client.py b/letta/llm_api/anthropic_client.py index feadb37a..6d920b5d 100644 --- a/letta/llm_api/anthropic_client.py +++ b/letta/llm_api/anthropic_client.py @@ -585,6 +585,8 @@ class AnthropicClient(LLMClientBase): # hack for incorrect tool format tool_input = json.loads(json.dumps(content_part.input)) if "id" in tool_input and tool_input["id"].startswith("toolu_") and "function" in tool_input: + if isinstance(tool_input["function"], str): + tool_input["function"] = json.loads(tool_input["function"]) arguments = json.dumps(tool_input["function"]["arguments"], indent=2) try: args_json = json.loads(arguments)