Agent calling multiple instances of tool n8n workflow for different queries , yet passes only one query to all instances

Problem

I’m using an n8n workflow that features an AI agent capable of breaking a complex query into multiple smaller sub-queries. Each sub-query is then sent to a “tool,” which is essentially another n8n workflow. Here’s the issue I’m running into:

  • When the agent splits the main query into three sub-queries, it calls the tool workflow three times (one for each sub-query). However, all three tool instances end up receiving only the first sub-query.
  • After realizing that two sub-queries went unanswered, the agent calls the tool again for those two. This time, two instances of the tool are spun up—but they both receive only the second sub-query.
  • Finally, once the agent is satisfied with the second query’s output, it calls the tool once more for the last sub-query.

My questions and concerns are:

  1. Why does the n8n agent generate multiple tool instances yet pass only the first sub-query (or the second, in subsequent calls) to all of them, instead of distributing each sub-query to its own instance?
  2. How can I configure my workflow so that each sub-query is processed correctly without creating redundant calls/instances?
  3. Given that the tool workflows themselves contain a few agents, what is the best way to optimize so the overall number of agent calls—and thus complexity—is reduced?

Any suggestions or insights into how to properly structure or synchronize these calls would be greatly appreciated!

n8n information setup
n8n version - 1.78.1
Running via docker
Operating system - Mac OS

2 Likes

Hi @A_Sriram ,

You should be able to write a system prompt for the agent step to handle this. One tools agent might be able to handle it, or we might want to use sub workflow to split the query and return three responses.

Can you upload your n8n workflow so I can take a look?

Best,

Robert

@A_Sriram ,

Here’s a sample workflow that splits the values and returns all three modified queries back.

Best,

Robert

  1. map each sub-query manually in the agent node (e.g., {{ $subquery1 }}, {{ $subquery2 }}).
  2. use item index if sub-queries are in an array (e.g., {{ $input.items[0].json.query }}).
  3. enable “sequential execution” in workflow settings to avoid overlap.

optimize:

  • cache results if sub-queries repeat.
  • reduce nested agents in tools to cut extra calls.

quick check: add a log node before tools to confirm correct inputs.

1 Like

Hi @A_Sriram,

Did any of these solutions solve your issue?

Best,

Robert