Skip to content

Anthropic→Gemini failover: function_response.name is empty, causes INVALID_ARGUMENT #41595

@DavidNielsen1031

Description

@DavidNielsen1031

Bug Report

OpenClaw Version: 2026.3.8 (3caab92)

Severity: High — failover silently produces invalid API requests

What happens

When the primary Anthropic profile times out and OpenClaw fails over to a Google/Gemini profile, the Anthropic→Gemini message format conversion leaves function_response.name empty on every tool result in the conversation history.

Gemini requires function_response.name to match the original function_call.name. The converter is not populating this field.

Error

GenerateContentRequest.contents[2].parts[0].function_response.name: Name cannot be empty.
GenerateContentRequest.contents[4].parts[0].function_response.name: Name cannot be empty.
... (repeats for every tool result, up to contents[168])

Status: INVALID_ARGUMENT (400)

Reproduction

  1. Configure both anthropic:* and google:* auth profiles
  2. Have a long conversation with many tool calls (50+)
  3. Cause Anthropic to timeout (e.g. during heavy load)
  4. Observe failover to Google profile
  5. Every function_response in the converted history has an empty name

Root cause (suspected)

Anthropic format stores tool results as tool_result blocks with tool_use_id. The tool name lives on the original tool_use block in the assistant message. When converting to Gemini format, the converter needs to look up the matching tool_use block by ID to get the name. This lookup appears to be missing.

Additionally, LCM (lossless context management) summarization may be stripping or not preserving tool names in compacted summaries, making the lookup impossible for older messages.

Log evidence

[agent/embedded] Profile anthropic:manual timed out. Trying next account...
[agent/embedded] google turn ordering fixup: prepended user bootstrap
[agent/embedded] embedded run agent end: isError=true error=LLM error: INVALID_ARGUMENT

This occurred 5 times across cron jobs and interactive sessions.

Workaround

Remove google:default from auth.profiles to prevent Gemini failover.

Expected behavior

The converter should populate function_response.name for every tool result by matching tool_use_id back to the corresponding tool_use block's name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions