A child loop resets its counter repeatedly
Detect: Parent accounting shows missing delegated consumption.
Recover: Charge child steps to inherited budgets and reject untracked work.
Terminate agent loops predictably when iteration, time, cost, or progress limits are reached, returning an honest partial outcome and a controlled next step.
A maximum-iterations fallback prevents an agent from continuing indefinitely when it repeats actions, cannot resolve uncertainty, or never emits a valid completion signal. Count the events that consume meaningful work: model turns, tool attempts, sub-agent calls, and repair loops may need separate counters. One global counter should still bound the complete parent task.
An iteration ceiling is a final containment mechanism, not a quality strategy. Combine it with elapsed-time, token, cost, and progress checks. When the limit is reached, stop starting new work, reconcile in-flight effects, and produce a defined terminal state rather than inventing a successful answer from incomplete evidence.
A prototype should have a small explicit ceiling and log why runs stop. Examine trajectories that hit the limit before increasing it.
Production reserves budget for finalization, cancellation, and safe result delivery. Nested agents and correction loops must consume inherited parent budgets rather than resetting their own unlimited counters.
At scale, tune limits by task class using observed success curves and marginal quality gains. Repeated limit exhaustion may reveal a broken tool, ambiguous objective, or routing error rather than unusually difficult work.
Tracks iterations, tool attempts, tokens, cost, and elapsed time across the full task tree.
Identifies repeated actions, unchanged evidence, and unresolved requirements without improvement.
Decides whether another step may start while reserving finalization capacity.
Cancels optional work and reconciles any in-flight side effects.
Reports completed work, missing evidence, stop reason, and an appropriate next action.
flowchart LR
T["Task limits and reserve"] --> G["Next-step admission"]
G --> A["Model or tool step"]
A --> P["Progress and usage update"]
P --> G
G --> F["Limit reached"]
F --> R["Cancel and reconcile"]
R --> O["Partial result or review"]
D["Delegated child usage"] --> PAssign task-class ceilings and reserve resources for finalization and recovery.
Increment counters consistently across model calls, tools, retries, and delegated work.
Compare new evidence and unresolved requirements to detect ineffective repetition.
Stop admission when any hard limit or no-progress condition is met.
Cancel safe optional tasks and determine outcomes of already-started commands.
Publish a partial, failed, or review-required state with verified artifacts and a clear reason.
Enterprise IT · Illustrative enterprise scenario, not a reported customer outcome.
An IT assistant investigates why a business application cannot connect to an approved database endpoint.
A missing permission causes repeated discovery calls, and the model keeps rephrasing the same query without obtaining new evidence.
The assistant must stop predictably and hand an administrator the useful diagnostics already collected.
A loop governor tracks tool fingerprints, evidence changes, and the shared iteration and time budget.
If a diagnostic task is still running, it is cancelled where supported; any completed administrative action is reconciled before final status is reported.
Measure limit-hit rate, repeated calls, useful partial results, and completion probability by allowed iteration count. Raising ceilings should require evidence of additional value.
| Decision | Benefit | Cost |
|---|---|---|
| Hard ceilings | Cost and runtime exposure become bounded. | Some difficult legitimate tasks stop before completion. |
| Progress-based stopping | Wasteful repetition can end earlier than the hard cap. | Progress is difficult to measure for some exploratory tasks. |
| Reserved finalization budget | The system can explain and reconcile a stopped run. | Less budget remains for primary investigation. |
Detect: Parent accounting shows missing delegated consumption.
Recover: Charge child steps to inherited budgets and reject untracked work.
Detect: Tool outcome remains pending when the loop stops.
Recover: Reconcile the command instead of declaring all work cancelled.
Mark missing evidence and partial completion explicitly.
Include tools, retries, and delegated work.
Diagnose repeated failure patterns first.