fix: anthropic payload tool parse error LET-5469 (#5388)

fix: anthropic payload tool parse error
This commit is contained in:
cthomas
2025-10-13 16:14:19 -07:00
committed by Caren Thomas
parent 5c35be42fb
commit 731e314b5d

View File

@@ -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)