When to reach for it
- The result can be iteratively improved.
- External validation triggers a retry.
- Tool results necessitate new iterations.
/pattern/loop/
One or more steps are repeated until a specific budget, quality bound, or exit condition is reached.
When to reach for it
When it backfires
The tradeoff
Adaptive improvement is achieved at the risk of endless or highly expensive execution loops.
A body step produces output; a check step decides whether to exit or loop again.
The check step always returns 'retry' because the quality threshold is set impossibly high.
Fix · Combine quality gate with a hard iteration cap. Treat cap exhaustion as a normal outcome, not an error.
Each loop appends to the same context. A bad intermediate gets baked in and the model compounds it rather than fixing it.
Fix · Keep only the latest iteration in context, or use a scratchpad that the model must explicitly update.
Search patterns, frameworks, and pages.