How I can create a wait in AI agent workflow

Hello Folks. Im creating a AI agente workflow. Im having a problem. I need the IA agent talk to users and after responds, the agent create the user profile. The big question is when The agent finalize I need to catch the output and create a structured json.

The question is each new interation with agent create a output.
for example :

iteration 1 → output 1
iteration 2 → output 2
the last iteration → final output

I would like to catch only the final output. But if I will connect anything node, the code node , each iteration o code node or something another catch the current ouput not the final output.

I think i would Have wait the final output but How I can do it ?

I use the n8n local.

@rc-ventura you need to show your json first

One idea is to let the Agent always output if its the final message and then have an if node afterwards that acts based on that. Do you have any conditions to check weather the message is “final”?