← Table of Contents · Page 578 of 868

RELIABILITY AND ERROR RECOVERY

Part 3 of 10

DETECTING AND BREAKING INFINITE LOOPS An agent runs in a loop by design, but sometimes the loop never ends. The agent may call the same tool with the same arguments again and again, hoping for a different answer, because the model has not recognized that the approach is failing. Each pass costs tokens and time, so a runaway loop can drain a budget quickly. Detection methods include these. Repetition detection: if the same tool is called with identical arguments several times in a row with no new information, flag it. Progress checks: if the agent has made many steps without any measurable progress, such as no new facts, no files changed, or no sub-goal completed, flag it. Hard limits: a maximum number of steps, a maximum time, and a maximum spend per run, enforced by the harness regardless of what the model wants. Breaking a loop can take several forms. Nudge: add a message to the conversation such as "You have tried this three times with the same result. Try a different approach." Change the tools or constraints: temporarily remove the failing tool. Escalate: hand the task to a human or a stronger model. Stop: end the run with a clear explanation, so that a stuck run does not continue forever. The limits must live in the harness, not in the model's instructions, because a model caught in a loop may ignore its own instructions.
Advertisement
Read Aloud:
0:00 / 0:00