Fix Gemini tool response format by including function name (#187)

Gemini requires the 'name' field in tool/function response messages,
while OpenAI infers it from tool_call_id. Without it, Gemini returns:
  'function_response.name: Name cannot be empty'

Added 'name' field to both tool result messages in the reflect agent.
This commit is contained in:
Chris Bartholomew 2026-01-23 01:38:51 -05:00 committed by GitHub
parent 9db64ecda3
commit 66abad61b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -436,6 +436,7 @@ async def run_reflect_agent(
{
"role": "tool",
"tool_call_id": done_call.id,
"name": done_call.name, # Required by Gemini
"content": json.dumps(
{
"error": "You must search for information first. Use search_reflections(), search_mental_models(), or recall() before providing your final answer."
@ -535,6 +536,7 @@ async def run_reflect_agent(
{
"role": "tool",
"tool_call_id": tc.id,
"name": tc.name, # Required by Gemini
"content": json.dumps(output, default=str),
}
)