Need help ensuring that my AI Agent gets the correct information after a Merge Node from prior agents. How to properly grab the correct information after Merge Append Node?

Detailed back ground information & issue I am facing:

So I have a workflow which calls the AI Agent. Note that this method is a batch processing workflow, meaning it scans my postgres database after the daily trigger and grabs all (1 or many) entries which have a specific value in a column.

After this, it makes some documents and does some AI processing based on the data in the postgres database. Everything up until after the Merge node is fine.

The issue shows up at the OutputAgent node all the way to the top right.

Let me describe the issue a bit more with an example:

Let’s say that I have got 3 entries in my postgres database that need to be processed, so it will get these 3 entries, and you can see that in this current execution screenshot that I have shown (directly below if you scroll down), there are 3 executions in all the three middle intermediary agents, the Business Extractor, ContactExtractor and ProductExtractor. That is correct ,there should be 3 because there are 3 separate rows (in this example run) that need to be processed as per my postgres database. Now the merge node has 9 items because I am in mode APPEND. But the problem is I think this is appending incorrectly, because it is appending all the three results from the first Agent the Business Extractor all together, and then the three from the Contact Extractor all together, and then the three from the final one all together. But I don’t want that structure, I need it to append the results of the three agents per ROW together, and then move on to the next one.

In my OutputAgent I need it to reference the information from the Business Extractor, ContactExtractor, and ProductExtractor per each row. And also, in my final agent OutputAgent it is saying it will execute 9 times? I only need it to execute 3 times, taking the information from the prior 3 agents (Business Extractor, ContactExtractor, and ProductExtractor). I’m just confused, how do I structure this properly, do I need to have another node after the merge that re-arranges it before it passes it into the final OutputAgent? Because right now I can’t properly grab the information I need from the Merge node to pass in to the OutputAgent But how do I have it so that it properly grabs the right element without me having to hardcode these values in cause they’ll fail for anything other than batch size of 3…

If someone can please help me with this i’d really appreciate it, I can pay for your time, I just need some help quickly with this.

No error message, I can’t even figure it out. I tried doing some stuff but I got an error message saying no path back to node, that lead me down the path that I need a Merge node, but maybe I also need something after the merge node, before the OutputAgent ?

Information on your n8n setup

  • n8n version: 1.89.2
  • Database (default: SQLite): Postgres, using AWS RDS
  • n8n EXECUTIONS_PROCESS setting (default: own, main): Not sure what this is, im sorry, I am testing the workflow now and then will have it run on a trigger daily or weekly.
  • Running n8n via (Docker, npm, n8n cloud, desktop app): I am running it via the website, and will deploy it on n8n I believe, not docker, not npm, and I don’t have an actual app for it on my laptop.
  • Operating system: Macbook M1 Pro, MacOs Sequoia 15.3.2

I’m really sorry for the massive post, but I tried to explain it as best as I can because it won’t let me post my actual workflow since there are some characters in it apparently (including elements of my IDs) that are blocked… Here is a screenshot though of an execution that I explained above, 3 row example.:

The issue is that the Merge append node is appending all three elements from the Business Extractor together, then the three from the Contact Extractor, and then three from the Product but I can’t have that because then I can’t dynamically access the variables needed in the OutputAgent because it won’t always be a batch process of 3 rows executing.

try run the agent in same row, you should be able to access then, so from google doc, connect all agent in row, into final edit node or code node maybe?

I believe the issue lies in your Merge node configuration.

To properly combine the outputs from the three AI agents, you need to ensure that there’s a common key to match on — typically an ID field that exists in all three outputs.

Example:

Agent 1
ID: 123
user_name: username

Agent 2:
ID: 123
location: userlocation

Agent 3:
ID: 123
age: userAge

The Merge node should match on the ID field across all inputs. Once that’s set, try adjusting the Merge Mode — in your case, selecting “Keep Matches” may yield the desired result.

@Anasp use this tutorial for more info about the merge node: Advanced Course (1/8) - Working with complex data flows