From f5c5034c62b3c1430ad0f882e8fcc66794d3e953 Mon Sep 17 00:00:00 2001 From: pHequals7 Date: Sun, 15 Feb 2026 18:32:48 +0000 Subject: [PATCH] fix(claude): resolve empty tool name in Claude API requests The ToolCall struct stores the tool name in Function.Name (OpenAI format) but the Claude provider was reading tc.Name (top-level), which is always empty. This caused 400 Bad Request errors on any conversation involving tool calls. Also handles the case where Arguments are stored as a JSON string in Function.Arguments rather than the top-level map. Co-Authored-By: Claude Opus 4.6 --- pkg/providers/claude_provider.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/providers/claude_provider.go b/pkg/providers/claude_provider.go index ae6aca96d..3fb6e94bf 100644 --- a/pkg/providers/claude_provider.go +++ b/pkg/providers/claude_provider.go @@ -81,7 +81,15 @@ func buildClaudeParams(messages []Message, tools []ToolDefinition, model string, blocks = append(blocks, anthropic.NewTextBlock(msg.Content)) } for _, tc := range msg.ToolCalls { - blocks = append(blocks, anthropic.NewToolUseBlock(tc.ID, tc.Arguments, tc.Name)) + name := tc.Name + if name == "" && tc.Function != nil { + name = tc.Function.Name + } + args := tc.Arguments + if args == nil && tc.Function != nil && tc.Function.Arguments != "" { + json.Unmarshal([]byte(tc.Function.Arguments), &args) + } + blocks = append(blocks, anthropic.NewToolUseBlock(tc.ID, args, name)) } anthropicMessages = append(anthropicMessages, anthropic.NewAssistantMessage(blocks...)) } else {