Termination Condition
A plan–act–observe loop has no natural end. The model produces a step, a tool runs, the result goes back into the context, and the loop comes round again — indefinitely, unless something is watching for a reason to stop. The termination condition is that something: the explicit test a runtime evaluates after each iteration to decide whether the agent goes round once more.
What ends a run
Most runtimes check several conditions at once, and they are not equivalent:
- Success — the model answers without requesting another tool call, or a checker confirms the goal state;
- Step limit — a hard ceiling on iterations, the backstop every loop needs;
- Budget — a token or cost cap, or a wall-clock timeout;
- No progress — a loop detector sees the same action producing the same observation;
- Handover — the agent pauses for human approval, or a person halts it.
In LangGraph this is written into the graph itself: an edge back to the agent node continues the loop, an edge to the end node stops it. AutoGen exposes termination as a composable condition on a conversation.
Why it matters
The distinction that earns its keep is between finishing and being cut off. An agent that stopped because it succeeded and one that stopped at iteration twenty-five look identical in the output unless the condition that fired is recorded — and only one of them is worth retrying. Weak termination logic is how one malformed request becomes a run that spends an entire budget on nothing.
A termination condition is the explicit test an agent runtime applies after each iteration to decide whether the loop stops — the goal being met, a step limit or token budget being exhausted, a timeout, a detected unproductive loop, or a handover to a person. Because a plan–act–observe loop has no natural end, it is what separates an agent that finishes from one that runs until it has spent everything it was allowed to spend.
Tell someone to tidy a room and they stop when it looks tidy. Tell a piece of software to pursue a goal and it has no such instinct — it will keep going, round and round, until something tells it to stop.
A termination condition is that instruction, written down in advance. Stop when the job is done. Stop after twenty-five tries. Stop when you have spent this much money, or taken this long, or clearly stopped making progress. It sounds like a small detail, but it is the difference between an AI agent that hands back an answer and one that quietly works all night achieving nothing.