Skip to content

Gemini API: function_response.name empty causes 400 INVALID_ARGUMENT #47857

@semiok

Description

@semiok

Bug Description

When using google/gemini-2.5-flash or google/gemini-3-flash-preview as agent model, every request fails with:

GenerateContentRequest.contents[N].parts[0].function_response.name: Name cannot be empty.

Gemini API requires function_response.name to be non-empty, but Gateway's google-generative-ai adapter sends tool result messages with empty name field.

Reproduction

  1. Set agent model to google/gemini-2.5-flash or google/gemini-3-flash-preview
  2. Send any message in a channel that has tool definitions (skills)
  3. Error occurs on every request, even after /new

Error Details

From gateway log:

{
  "error": {
    "code": 400,
    "message": "* GenerateContentRequest.contents[6].parts[0].function_response.name: Name cannot be empty.\n* GenerateContentRequest.contents[8].parts[0].function_response.name: Name cannot be empty.\n",
    "status": "INVALID_ARGUMENT"
  }
}
  • Positions contents[6] and contents[8] are consistent across requests (before /new)
  • After /new with LCM context injection, positions shift to contents[98] and contents[100]
  • Both gemini-2.5-flash and gemini-3-flash-preview affected
  • Other providers (anthropic, mm/MiniMax, moonshot) work fine with same session

Root Cause Hypothesis

Gateway converts internal OpenClaw message format to Gemini's GenerateContentRequest. Tool result messages (tool_result / function_response) need a name field matching the original function call. The converter appears to lose the function name during this translation.

Environment

  • OpenClaw 2026.3.13
  • API: google-generative-ai (v1beta)
  • macOS Darwin 24.6.0

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