From the course: Build AI Agents and Automate Workflows with n8n

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Using a sub-workflow as a tool

Using a sub-workflow as a tool

- [Instructor] Okay, this setup works, but you may have spotted that there's a problem here. You can see it right down here. The number of tokens being passed into the model is really high. And that's because when we call the model, after the Google Sheets lookup, all the information from the sheet is passed back to the AI model. That's okay when we only have 10 entries, but if I switch over to the main sheet with over 100 lines, it becomes an awful lot of data. And this is just an example of a small database. If you imagine a much larger database or much bigger data, passing all that data into the model would not only cause the model to not work properly because there's too much data to parse through, but would also be really wasteful because you're paying per token when you're using any of the APIs for these AI models. And passing in tons of wasted tokens is wasted money and wasted energy. To fix this, we somehow have to get the agent to tell Google Sheets to only return the…

Contents