From 3b59eae7c0a87f95368ee5da0e87f48b5837a461 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 28 Nov 2025 20:22:05 +0200 Subject: [PATCH] Gemini: Only register custom tools when there are no function tools --- src/endpoints/backends/chat-completions.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/endpoints/backends/chat-completions.js b/src/endpoints/backends/chat-completions.js index 207cedbfb..31d49e693 100644 --- a/src/endpoints/backends/chat-completions.js +++ b/src/endpoints/backends/chat-completions.js @@ -423,6 +423,7 @@ async function sendMakerSuiteRequest(request, response) { if (Array.isArray(request.body.tools) && request.body.tools.length > 0 && !enableImageModality && !isGemma) { const functionDeclarations = []; + const customTools = []; for (const tool of request.body.tools) { if (tool.type === 'function') { if (tool.function.parameters?.$schema) { @@ -433,12 +434,16 @@ async function sendMakerSuiteRequest(request, response) { } functionDeclarations.push(tool.function); } else if (tool[tool.type]) { - tools.push({ [tool.type]: tool[tool.type] }); + customTools.push({ [tool.type]: tool[tool.type] }); } } if (functionDeclarations.length > 0) { tools.push({ function_declarations: functionDeclarations }); } + // Custom tools are only supported when no function calling is present + if (functionDeclarations.length === 0 && customTools.length > 0) { + tools.push(...customTools); + } } if (enableWebSearch && !enableImageModality && !isGemma && !isLearnLM && !noSearchModels.includes(model)) {