← Table of Contents · Page 101 of 868

THE CORE AGENT LOOP

Part 6 of 12

TERMINATION CONDITIONS A loop that never stops is a bug. So every agent loop needs termination conditions, which are the rules that decide when the agent should stop. There are several common ones, and a good harness uses more than one at once. The first is the success signal. The model itself indicates it is finished, either by giving a final answer instead of asking for a tool, or by writing a special marker such as TASK_COMPLETE that the harness is watching for. The second is a harness-side check. Instead of trusting the model's claim, the harness may test the result, for example by running a checking program to confirm that a file was really created. Trusting a model's statement of success without checking is risky, because models can say "done" when the work is incomplete. The third is a failure signal. If the agent keeps hitting errors that it cannot fix, the harness stops the loop and reports the problem. The fourth is a human stop. A person may press a cancel button, and the harness must honor it quickly. The fifth is a limit on resources, such as steps, time, or money. That fifth family deserves its own section.
Advertisement
Read Aloud:
0:00 / 0:00