How to create a feedback loop with AI Agents

Hello,

I’m interested in building “AI Agents” solutions where a second Agent provides feedback to a first Agent. Suppose for instance that one wants to build the following scenario:

  1. The User chats with Agent 1
  2. Agent 1 (which could also use some tools) generates a response, but this is not directly prompted to the User, but is instead sent to Agent 2
  3. Agent 2 has rules on how to evaluate the response provided by Agent 1, and can do two things: (a) if the response is valid, send it to the User; (b) if there is something wrong, send it back to Agent 1 with some feedback comments on how to improve. The flow starts back from (2).

The following example lacks of the feedback, and this is only because I haven’t understood how can I accomplish this with n8n.

I have seen in many tutorials that the “Execute Sub-Workflow” is being used as a tool of Agent 1, but this does not 100% fit the scenario I have described, mainly because the usage of a tool is something that the Agent “decides”.