A single AI agent sometimes stops early. It says "let me look at that", then ends its turn, or it stops after the first of five things you asked for. A pipeline lets you put a second agent behind it whose only job is to check the work and decide: is this done, or should the first agent keep going? This guide shows how to build that loop and what changed in how pipelines handle it.
Lines now always continue
A line between two agents means one thing: the next agent starts only after the previous one has finished completely. That means every tool call has been made and the agent has given an answer without asking for another tool. You no longer need to force this with a setting. The second agent never sees half-finished work.
What the checker sees
The checker does not receive the whole conversation, which would be slow and expensive. It receives only the last reply of the first agent, through the variable {{step_N_output}}, where N is the step's number in run order (the Input step is step 1).
When a line goes back to an earlier agent, the earlier agent is told what happened: it receives its own previous answer plus a short note that the checker sent it back to continue. So the worker knows why it is running again, without you writing that logic.
Building the loop
- Add two agents: Worker and Checker.
- Draw a line from Worker to Checker. Draw a second line from Checker back to Worker.
- Give the Checker a prompt like the one below.
- On the line from Worker to Checker, add a Break if condition (see below) so a finished worker can skip the checker entirely.
A Checker prompt that works well:
You review the last answer from the Worker:
{{step_2_output}}
If the task is fully done, reply with exactly: [[FINISHED]]
If anything is missing or unfinished, reply with one short
sentence saying what the Worker must do next. Do not do the
work yourself.
The finish marker
A marker such as [[FINISHED]] is the signal that stops the loop. You set it in the line's Break if field; the match is a case-insensitive "contains", so finished catches FINISHED and Finished. alike.
Two details make this pleasant to use. The marker and the "Break condition met" notice are hidden in the chat, so your conversation reads naturally. And the same applies to words like DONE or FINISHED when the AI uses them as a stop signal: they stop the run but do not clutter the answer.
Loop limits and the infinity switch
Every loop needs a safety limit so it cannot run forever by accident. There are two:
- Agent max: how many times a line may send work back to an agent.
- Tool max: how many tool calls one agent may make in one turn.
Both used to be plain numbers. If you typed 50 on the closing line, the run could still stop with "Max iterations (5) reached", because the closing line's value was not the one being used. That is fixed: the limit you set on the line that closes the loop is the one that counts. A loop line with no limit set still defaults to 5, which is a safe starting point.
Each limit now has an infinity switch. Turn it on and the limit disappears; the loop runs until the Checker says it is finished, or until your budget runs out. Use it for long, genuinely open-ended work, but pair it with a clear finish marker. Your AI budget still applies, and a run stops mid-way when it is used up.
When the worker says nothing
Sometimes a model thinks for a while and then returns no text at all. Previously the checker received an empty string and could not tell what happened. Now the variable contains the text EMPTY REPLY, so you can handle it in the Checker prompt:
If the Worker's answer is "EMPTY REPLY", it stopped without
responding. Tell it to continue with the task.
Tips
- Keep the Checker's prompt short and strict. Its only output should be the marker or one instruction.
- Use the step number shown on each agent card when writing
{{step_N_output}}. - If a loop seems to run forever, look at what the Checker answers. A Checker that never says the marker is almost always the cause.
New to pipelines? Start with Pipeline Tool Call Transparency, then build your first loop in a demo project.