How do n8n agents decide which tool to use? Anyone can point me to the part of the source code where it happens?

I know that generally they do it from tool descriptions and also the system prompt, but n8n is doing something in the backend to rewrite the query and choose the tools, format the output, etc.

Anyone knows how exactly it happens where the relevant part in the source code is that deals with it?

Thanks!

1 Like