From 8384a8c5b321846591df33996ab71e7b9453a616 Mon Sep 17 00:00:00 2001 From: dtighe <2289888+dtighe@users.noreply.github.com> Date: Tue, 18 Aug 2026 07:16:47 -0700 Subject: [PATCH] Fix Gemini tool calling on 3.6+ by using documented function response role (#24013) Gemini 3.6 and newer reject role="function" on the function response Content with 400 INVALID_ARGUMENT, breaking any chat query that triggers a tool call. The tool call itself succeeds; only the hand-back to the model fails, and because the error surfaces mid-stream the request still returns HTTP 200, so it is easy to miss. Google's function calling documentation specifies role="user" for returning function results: contents.append(response.candidates[0].content) contents.append(types.Content(role="user", parts=[function_response_part])) https://ai.google.dev/gemini-api/docs/generate-content/function-calling Verified with my local setup. --- frigate/genai/plugins/gemini.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frigate/genai/plugins/gemini.py b/frigate/genai/plugins/gemini.py index 1c89806082..4af29ff8c9 100644 --- a/frigate/genai/plugins/gemini.py +++ b/frigate/genai/plugins/gemini.py @@ -245,7 +245,7 @@ class GeminiClient(GenAIClient): ) gemini_messages.append( types.Content( - role="function", + role="user", parts=[ types.Part.from_function_response( name=msg.get("name") @@ -501,7 +501,7 @@ class GeminiClient(GenAIClient): ) gemini_messages.append( types.Content( - role="function", + role="user", parts=[ types.Part.from_function_response( name=msg.get("name")