-
-
Notifications
You must be signed in to change notification settings - Fork 923
Description
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
- Spawn an agent using a Gemini provider model (e.g.,
openfang agent new coder). - Ensure the agent has the
shell_execcapability enabled in itsagent.toml. - 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").
- 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.