From 0d1ad45661e2ecebd4c75e77c37d6c682b012cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E6=96=87=E9=94=8B0668000834?= Date: Wed, 18 Mar 2026 17:21:17 +0800 Subject: [PATCH] fix(anthropic): skip tool calls with empty names to prevent API errors When building parameters for Anthropic API calls, tool calls with empty names would cause 400 Bad Request errors with the message: 'tool_use.name: String should have at least 1 character' This fix adds a check to skip tool calls that have empty names, preventing the API error and allowing the conversation to continue normally. Fixes #1658 --- pkg/providers/anthropic/provider.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/providers/anthropic/provider.go b/pkg/providers/anthropic/provider.go index 242ded1757..d4ceaab2cd 100644 --- a/pkg/providers/anthropic/provider.go +++ b/pkg/providers/anthropic/provider.go @@ -180,6 +180,10 @@ func buildParams( blocks = append(blocks, anthropic.NewTextBlock(msg.Content)) } for _, tc := range msg.ToolCalls { + // Skip tool calls with empty names to avoid API errors + if tc.Name == "" { + continue + } args := tc.Arguments if args == nil && tc.Function != nil && tc.Function.Arguments != "" { if err := json.Unmarshal([]byte(tc.Function.Arguments), &args); err != nil {