Infinite loop between AI Agent and chat model

Describe the problem/error/question

Hello, I have an infinite loop between the AI Agent and the chat model. I tried a lot of different situations and found out that certain nodes before the ai agent was creating the bug. On my workflow, the trigger is manual, the matrix node get the messages, the Editfields node create a string named action and the AI agent use it = Infinite loop.

Then if I just turn off matrix node, it doesn’t change what the Editfields node create and AI Agent receive but then it only runs once and stop perfectly.

What is the error message (if any)?

No error message

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.112.4
  • Database (default: SQLite): PostgreSQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker on a server
  • Operating system: Linux

Hi @kevin_pocky

What do you mean by “infinite loop”?!

From the attached workflow, the matrix node gets the messages (“Get many messages”) and is configured to return 100:
image

This means the node output will be 100 items, which causes the Set node to execute 100 times, and as a result, the AI Agent will also execute 100 times..

Hi @mohamed3nan , thanks for your answer.

Infinite loop means it goes from AI Agent to to the chat model, then go back to ai agent, then back to chat model, then back to ai agent, … infinitely.

Neither the Editfields node or AI Agent get any item from the matrix node. Edit fields 1 create a string the AI Agent get “{{ $json.action }}”.

Then if I turn off the Matrix node, it doesn’t change anything to Edit Fields 1 and AI Agent but the AI Agent only ask the chat model once and it is done.

Edit : OK that is it, even if the data isn’t used, it get items anyway so I need to clean the number of items before it reach the AI Agent.

1 Like

yes exactly…

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.