n8n AI agent NOT calling the right TOOL - easy fix

How to Fix N8N Workflow Not Calling the Right Tool


Hi there! If you're watching this video, you probably have the same issue as me - the N8N workflow is not calling the right tool even though you've named it and created it.



The Problem


Looking at my workflow, I have my AI agent, I have the tools agent, and I have literally one tool. My task is to receive an Upwork job description and then use it to generate an application copy with the tool "generate application copy".


But when I run this, it's not calling the tool! The tool's description is "Use this tool to generate an Upwork application copy." I've selected everything correctly, and this is the workflow here. It's already triggered by another flow. I'm accepting all data, but it just isn't working.



The Solution


I just found out the problem for myself. It was a simple issue, but I'm going to show you how to fix this.


The first problem might be that you're calling too many agents. Here, I simplified it to calling one simple agent.


The other problem I was having was I used "defined below" and then I was putting the system message and also another system message. This was feeding in this text into the module every single time.



Steps to Fix


  • Make the tools clearer with the names and descriptions.


  • For the system message (which should be at the top but that's how it is), you need to dynamically get it from the chat trigger node.


  • If you use "define below," you have to pull that in. It's basically the same thing, but just use the automatic one.


  • You can use Gemini or GPT-4 Mini - both work well.


  • Make sure you have the name of your tool from the list (you can also use by ID).


  • Tell it clearly: "Use this tool to generate Upwork application copy. The input will be this and the output will be this."



  • Testing the Fix


    When I run it now, it's running through and generating a response with ChatGPT. It's calling the tool right there and going back to the ChatGPT model to give us the answer.


    The output here is "Here's a tailored application..." which is exactly what we want!



    Full Chat Test


    I deleted the previous chat and tested with a real Upwork job description. I copied the job description that mentioned building a workflow with N8N, GPT Cloud, etc.


    When I pasted it into the chat with "Here is a job description," it went to the AI agent, called the tool, came back, and gave me a formatted application.



    FAQ


    Q: Why wasn't my tool being called?


  • A: The most common issues are either having too many agents competing, or not properly passing the input from the chat trigger to the AI node.

  • Q: How do I make sure my tool description is clear enough?


  • A: Be explicit about what the tool does, what input it expects, and what output it will provide.

  • Q: Can I use different AI models for this?


  • A: Yes, both Gemini and GPT-4 Mini work well for this purpose.

  • I hope you enjoyed this! I know it's a simple thing to mess up, but since I was stuck on this for 30 minutes, I figured someone else might be too.


    Let's build great things!

    More educational blogs: