An agent loop repeats when the tool result never satisfies the model: the agent calls the tool, reads a result it cannot use, and calls the tool again. The execution log shows the repeat, and the fix is usually in the tool result or the instructions, not in the model.
Before you start
You need a failing n8n execution where the agent called the same tool at least three times. Open the log before you change anything, so you know the exact call that repeats.
Read the log and name the repeated call
Open the execution and list the tool calls in order. Find the call that repeats and read what it returned each time: an empty result, an error, or a result in a shape the model does not understand. The model repeats the call because it is waiting for a usable answer.
Fix the result, then add a stop rule
Fix the tool so it returns a usable result, or change the system message to say what to do when the tool returns nothing, for example answer from the available facts and stop. Set Max Iterations low while you test, so a still-looping agent stops after a few turns.
Worked example: A repeating lookup for a fictional support agent
Northwind Support is a fictional help desk. Its agent repeated an order lookup five times. The table shows the calls.
| Call | Tool | Result returned |
|---|---|---|
| 1 | Order lookup for 1042 | Empty, no order found |
| 2 | Order lookup for 1042 | Empty, no order found |
| 3 | Order lookup for 1042 | Empty, no order found |
| Fix | Order lookup returns a not-found message | Agent replies that the order was not found |
Expected result (UNTESTED): after the fix, the same question produces one tool call and a reply that the order was not found. We checked the n8n tutorial, which describes the tool-calling loop and the Max Iterations stop, but we did not run the failing workflow on a live n8n instance.
Limits
A stop rule hides a broken tool: the agent stops looping, but the underlying lookup is still broken. Fix the tool result first, and use the stop rule only as a safety net.
