From 66abad61b83b581ad64e20321c77e0d5c42bbff4 Mon Sep 17 00:00:00 2001 From: Chris Bartholomew Date: Fri, 23 Jan 2026 01:38:51 -0500 Subject: [PATCH] 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. --- hindsight-api/hindsight_api/engine/reflect/agent.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hindsight-api/hindsight_api/engine/reflect/agent.py b/hindsight-api/hindsight_api/engine/reflect/agent.py index 4f09d5b6..e4925eeb 100644 --- a/hindsight-api/hindsight_api/engine/reflect/agent.py +++ b/hindsight-api/hindsight_api/engine/reflect/agent.py @@ -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), } )