From af5bd42df7db5e887f07bc7618d5751e89965c11 Mon Sep 17 00:00:00 2001 From: Rat0323 <261020116+Rat0323@users.noreply.github.com> Date: Fri, 12 Jun 2026 12:22:06 +0800 Subject: [PATCH 1/3] fix(gemini): automatically disable thinking config when tools are present --- astrbot/core/provider/sources/gemini_source.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/astrbot/core/provider/sources/gemini_source.py b/astrbot/core/provider/sources/gemini_source.py index f38fcfc359..8d2e79907d 100644 --- a/astrbot/core/provider/sources/gemini_source.py +++ b/astrbot/core/provider/sources/gemini_source.py @@ -292,6 +292,11 @@ async def _prepare_query_config( else: thinking_config.thinking_level = level + # If any tools (native or custom function declarations) are active for this request, + # we must disable thinking because Gemini API does not support them simultaneously. + if tool_list: + thinking_config = None + return types.GenerateContentConfig( system_instruction=system_instruction, temperature=temperature, From ded983f1e631f5f7e7597b32b96a2593f7eeb55d Mon Sep 17 00:00:00 2001 From: Rat0323 <261020116+Rat0323@users.noreply.github.com> Date: Fri, 12 Jun 2026 20:37:28 +0800 Subject: [PATCH 2/3] chore(gemini): log warning when thinking is automatically disabled due to active tools --- astrbot/core/provider/sources/gemini_source.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/astrbot/core/provider/sources/gemini_source.py b/astrbot/core/provider/sources/gemini_source.py index 8d2e79907d..da2940048f 100644 --- a/astrbot/core/provider/sources/gemini_source.py +++ b/astrbot/core/provider/sources/gemini_source.py @@ -294,7 +294,8 @@ async def _prepare_query_config( # If any tools (native or custom function declarations) are active for this request, # we must disable thinking because Gemini API does not support them simultaneously. - if tool_list: + if tool_list and thinking_config: + logger.warning("[Gemini] Thinking config is automatically disabled because tools are active for this request.") thinking_config = None return types.GenerateContentConfig( From 851b5267b7c8c50669a3172eba374c9c32130a1e Mon Sep 17 00:00:00 2001 From: Rat0323 <261020116+Rat0323@users.noreply.github.com> Date: Fri, 12 Jun 2026 21:07:09 +0800 Subject: [PATCH 3/3] chore(gemini): prevent warning log when thinking_budget is 0 --- astrbot/core/provider/sources/gemini_source.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/astrbot/core/provider/sources/gemini_source.py b/astrbot/core/provider/sources/gemini_source.py index da2940048f..c23dab6926 100644 --- a/astrbot/core/provider/sources/gemini_source.py +++ b/astrbot/core/provider/sources/gemini_source.py @@ -295,7 +295,10 @@ async def _prepare_query_config( # If any tools (native or custom function declarations) are active for this request, # we must disable thinking because Gemini API does not support them simultaneously. if tool_list and thinking_config: - logger.warning("[Gemini] Thinking config is automatically disabled because tools are active for this request.") + if getattr(thinking_config, "thinking_budget", None) != 0: + logger.warning( + "[Gemini] Thinking config is automatically disabled because tools are active for this request." + ) thinking_config = None return types.GenerateContentConfig(