Skip to content

bug: Gemini driver fails with "Name cannot be empty" on tool execution #136

@mcagriardic

Description

@mcagriardic

Gemini Tool Execution 400 Bad Request — Missing function_response.name

Summary

When using Gemini models (tried with gemini-2.0-flash, gemini-2.5-flash), any tool execution (specifically tested with shell_exec) triggers a 400 Bad Request error from the Google API because the function_response payload lacks a name field.

Problem

When an agent (like the default coder template or a custom agent) successfully executes a tool, the OpenFang Gemini driver improperly formats the payload sent back to the Google API with the tool's result. The name field inside function_response is omitted or left empty.

Google's API strictly requires this field and immediately rejects the request, causing the agent loop to panic and return an empty response guardrail to the user.

Exact error from daemon logs

WARN openfang_runtime::agent_loop: LLM error classified: LLM request failed. Check your API key and model
configuration in Settings. category=Format retryable=false raw=API error (400): *
GenerateContentRequest.contents[2].parts[0].function_response.name: Name cannot be empty.

Steps to Reproduce

  1. Spawn an agent using a Gemini provider model (e.g., openfang agent new coder).
  2. Ensure the agent has the shell_exec capability enabled in its agent.toml.
  3. Prompt the agent to run a basic shell command (e.g., "Use your shell_exec tool to run 'echo hello' and tell me the output").
  4. The tool executes successfully on the host system, but the subsequent LLM request fails with the 400 error, leaving the agent unresponsive.

Solution

Update the Gemini driver in openfang_runtime::drivers::gemini to correctly map the tool_name into the function_response.name field when constructing the history payload after a tool is executed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions