Gemini Printing Tool Calls Instead of doing them - Tools Agent Node Not Compatible with Gemini

Describe the problem/error/question

The “Tools Agent” node in N8N does not seem to be working correctly with Gemini models. While it functions as expected with GPT models, when using Gemini, the agent fails to trigger the defined tools. Instead of executing the tool (e.g., sending an email or making an API call), the output shows what looks like the function call itself, such as print(default_api.Enviar_Guia_Disenos(input=True)).

I also see that in this documentation, there is no mention of Tools Agent being compatible with Gemini Chat Models, but I want to make sure this is not outdated (as I see a lot of content combining Tools Agent + Gemini):

Is there a different way or something to take into account before using Gemini to build Agents?

What is the error message (if any)?

There is no specific error message from N8N. The output of the “Tools Agent” node when using Gemini models is the string representation of what appears to be the intended tool call, rather than the result of the tool execution.

Please share your workflow

Share the output returned by the last node

When using a Gemini model, the “Tools Agent” node outputs a string like:

print(default_api.Enviar_Guia_Disenos(input=True))

Instead of the action defined in the tool “Enviar_Guia_Disenos” being executed.

Information on your n8n setup

  • n8n version: 1.84.1 (But this is happening with all versions)
  • Database (default: SQLite): Postgress
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Linux

You may want to add much greater descriptions to your tool calls and to explain how inputs work/arguments etc.

That is already done, and the agent is able to call the tools, but some times it suddenly prints the call instead of actually calling it…

What model are you trying to use exactly? Unsure if I saw.

Specially with Gemini 2.0 flash.

Thanks

Have you tried starting with only one or two tool calls and improving the descriptions? To help see if something odd is going on because of how many tool calls are there.

Okey, let me check…

I have been checking and no, this is not solved.

This has to be some incompatibility with Gemini.

No matter which Gemini Model I use, it always happens, but it doesn´t as soon as I change to one of OpenAI (even the dumbest ones)…

So I encountered something similar, and being explicit in the sys prompt and user prompt to not wrap any of its values or tool calls in formatting strings / backticks seems to have solved it for me. Unsure if that is the same issue.

This error is happening to me quite frequently, but not always. It seems that there comes a time when the AI ​​Agent gets lost and instead of calling the tool, it prints a log of the tool’s execution.
I don’t know what else to do to solve this problem. I don’t know if it has a direct relationship with Gemini because I don’t use another model to test.