Nothing inside an n8n AI agent judges the loop. It stops when the model answers without requesting a tool, or when it hits the Max Iterations option on the node. That option is the safety net: set it low while you test, and raise it only when you know how many turns a normal task needs.
Before you start
You need an n8n workflow with a working AI Agent node and at least one tool attached. Note the current Max Iterations value first: the tutorial we checked records the default as 10.
Set the limit and watch a run hit it
Open the AI Agent node, open Options, and set Max Iterations to 4 for a first test. Save the workflow and send a prompt that is likely to loop, for example a question that needs a tool result the tool cannot return. Open the execution log and count the model turns: the run should stop after the fourth turn and return an error or a partial answer instead of running on.
Pick a working value from your own runs
Run five ordinary tasks and note how many turns each one takes. Set the limit to the highest normal count plus two, so ordinary work finishes and only a loop gets cut off. A limit of 4 is a test value, not a working value: most real tasks need more turns than that.
Worked example: Five ordinary tasks on a fictional support agent
Northwind Support is a fictional help desk. Its agent answers order questions with one HTTP tool. Five test tasks show how many turns normal work takes.
| Task | Model turns used | Limit of 4 stops it? |
|---|---|---|
| Check order 1042 status | 2 | No |
| List the last 3 orders | 3 | No |
| Find the delivery date for order 1042 | 2 | No |
| Compare two delivery options | 4 | No, it finishes on the fourth turn |
| Ask a question the tool cannot answer | 4, then stopped | Yes, the limit cut the loop off |
Expected result (UNTESTED): the five ordinary tasks finish within 4 turns, and the unanswerable question stops after the fourth turn instead of looping. We checked the n8n tutorial, which records the Max Iterations default of 10 and the stop rule, but we did not run the test on a live n8n instance.
Limits
Max Iterations counts model turns, not tool calls, and a low limit can cut off a legitimate long task. It does not limit what the model costs per turn, and it does not stop a tool that is slow on its own. Use it together with a per-run time check on the workflow.
