Skip to content

fix(anthropic): skip tool calls with empty names to prevent API errors (#1658)#1739

Merged
yinwm merged 1 commit intosipeed:mainfrom
darrenzeng2025:fix/1658-empty-tool-name
Mar 18, 2026
Merged

fix(anthropic): skip tool calls with empty names to prevent API errors (#1658)#1739
yinwm merged 1 commit intosipeed:mainfrom
darrenzeng2025:fix/1658-empty-tool-name

Conversation

@darrenzeng2025
Copy link
Contributor

Description

This PR fixes issue #1658 where Anthropic API returns 400 Bad Request error when tool calls have empty names.

Problem

When messaging PicoClaw with Claude models, users consistently get this error:

LLM call failed after retries: claude API call: POST "https://api.anthropic.com/v1/messages": 400 Bad Request
{"type":"error","error":{"type":"invalid_request_error","message":"messages.11.content.1.tool_use.name: String should have at least 1 character"}}

Root Cause

When building parameters for Anthropic API calls in buildParams(), tool calls with empty names were being passed directly to the API, which rejects them.

Solution

Added a simple check to skip tool calls that have empty names before constructing the API request. This prevents the API error and allows the conversation to continue normally.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

AI Code Generation

  • 🤖 Fully AI-generated

Related Issue

Fixes #1658

Technical Context

Similar fix was implemented in OpenClaw: openclaw/openclaw@aa56045

Test Environment

  • PicoClaw Version: main branch
  • Go Version: 1.25.7
  • AI Model & Provider: Claude via Anthropic

Checklist

  • I have read and understood the Contributing Guide
  • My code follows the project's code style
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have linked the related issue

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 sipeed#1658
@yinwm yinwm merged commit 54654d2 into sipeed:main Mar 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]tool use.name string should contain at least 1 character - Claude

3 participants