« All posts

Designing a Coding Agent Loop: Goals, Verification, Stopping

How to design a coding agent loop: goal-check separation, a verification ladder, isolated attempts, and explicit stopping states.

A prompt tells a coding agent what to do once; almost everything that matters happens after the first result comes back wrong, and until now the developer has been the one carrying evidence between attempts and deciding when work is truly done. This piece frames a loop that sits outside the model itself — request, goal, attempt, verify, decide — and argues for separating the goal (what should become true) from the check (the evidence used to judge it), treating verification as a ladder from cheap self-reports up to real product runs and independent review. It draws on recent coding-agent research showing that full-cycle autonomy (environment setup, implementation, testing) sharply degrades performance, and that structured reviewer feedback beats one-shot generation. It also stresses that retries need new evidence, isolated worktrees keep attempts comparable, and memory should stay selective rather than accumulate full transcripts. Explicit terminal states — success, blocked, exhausted, cancelled, error — matter as much as the retry logic itself; fixed iteration caps waste effort, while unbounded loops risk becoming real infinite-loop defects, as recent static-analysis findings confirm. The loop should remain inspectable at every point: what's the goal, which attempt is live, what changed, and why did the last one fail.