From b035fda7781b2102af8eb9270f951807d74b5c66 Mon Sep 17 00:00:00 2001 From: Neal Shah <30693865+ProgrammerIn-wonderland@users.noreply.github.com> Date: Thu, 20 Nov 2025 16:57:39 -0500 Subject: [PATCH] Fix gemini when tools are null (#1992) --- .../modules/puterai/lib/FunctionCalling.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/backend/src/modules/puterai/lib/FunctionCalling.js b/src/backend/src/modules/puterai/lib/FunctionCalling.js index 00f438aa7..0b9fe4aff 100644 --- a/src/backend/src/modules/puterai/lib/FunctionCalling.js +++ b/src/backend/src/modules/puterai/lib/FunctionCalling.js @@ -121,14 +121,17 @@ module.exports = class FunctionCalling { } static make_gemini_tools (tools) { - return [ - { - function_declarations: tools.map(t => { - const tool = t.function; - delete tool.parameters.additionalProperties; - return tool; - }) - } - ]; + if (Array.isArray(tools)) { + return [ + { + function_declarations: tools.map(t => { + const tool = t.function; + delete tool.parameters.additionalProperties; + return tool; + }) + } + ]; + }; + } }