Aglio blog

November 24, 2026 · Aglio team · 3 min read

Knowing when to stop a run

Long agent runs rarely get better near the end. Set a budget, watch for loops, and hand back to a person while the context is still useful.

An agent that has failed twice will usually fail a third time in a slightly different way. The diff grows, the explanation gets longer, and the original requirement drifts out of view. Every extra attempt costs tokens and review attention, and the probability of a clean result goes down.

Stopping well is a design decision, not a mood.

Set the budget before the run

Decide how much effort the card deserves while you still know what it is worth. A typo fix gets one attempt and a build. A migration gets a plan, a rehearsal against a copy, and a verification step. Written as a limit, the decision applies to every run of that card instead of to whoever is watching at midnight.

Budgets come in three kinds: attempts, wall-clock time, and money. Pick the one that matches the risk. Loops burn time and tokens, so a time limit catches them. A run stuck waiting on a flaky check burns wall-clock without spending much, so an attempt limit is the better guard.

Watch for the shape of a loop

Repeated failure has a signature. The agent re-reads the same three files. The same test fails with the same message after an edit that claimed to fix it. The plan restarts from step one. The summary uses the word "however" more than once.

None of those require reading the whole transcript. A run that revisits the same failing check twice with no change in the error is not converging, and another turn will not change that.

Stop with a report, not a shrug

A stopped run should leave something a person can pick up: what was attempted, what failed, which files changed, and what the agent believes is blocking. The next step is often obvious from that note, and it is often not something an agent should do, like confirming a product decision or asking for credentials.

A run that dies silently teaches nobody anything. A run that stops with a diagnosis turns into a five-minute conversation.

Hand back before the context is gone

The most expensive failure is an exhausted run that also used up the reviewer's patience. Hand over early, while the requirement is fresh and the diff is still small enough to read in one sitting. Small abandoned diffs are cheap. Large abandoned diffs get merged out of fatigue, which is the worst possible reason.

Retries need new information

Before a retry, ask what changed. A sharper error message, a corrected assumption, a narrower scope: these justify another attempt. "Try again" does not. If the retry prompt is the same as the first, the result will be the same class of result, and the only thing that grew is the bill.

Cap, inspect, decide

Pick a limit. Let the run hit it. Read the report. Then decide whether the next unit of work is another attempt, a smaller card, or a person's ten minutes. The decision is cheaper than the loop, and it is the only part of the process that needs judgement.