Goal-based agent loops: giving a coding agent a definition of done
A goal-based loop keeps a coding agent iterating until a success criterion is met. The trick is a deterministic definition of done — tests, a score, a proof — not an LLM guessing at "good enough." How to write one.
A goal-based agent loop keeps a coding agent working until a success criterion you defined is met, so the agent never decides "good enough" on its own and stops early. Instead of one turn, you give it a definition of done and a turn cap. Each time it tries to stop, something checks the criterion and either accepts the result or sends it back to work. The quality of the loop comes down entirely to how good, and how deterministic, that definition of done is.
Why a definition of done matters
Left to itself, an agent stops when it believes the task is complete. That belief is often wrong: it edited the file, the edit compiled, so it declares victory, without running the thing. A definition of done removes the judgment call. "The change is done when the test suite passes and the Lighthouse score is ≥ 90" is not a matter of opinion; it's a gate. The more quantitative the criterion, the easier it is for the agent to self-verify and the less it over- or under-shoots.
Deterministic criteria beat an evaluator's opinion
There are two ways to check "done." One is to ask an evaluator model whether the condition looks met: flexible, but it's another probabilistic judgment. The other is a deterministic check: a test that passes or fails, a score above or below a line, a proof that a goal's functions are actually wired into the code. Aura leans on the deterministic side. A goal is recorded in .aura/goals.jsonl, and when the agent finishes, Aura proves the resulting commit against it (checking which functions exist, which paths are connected, and whether the stated intent matches the actual AST change) then records a verdict you can verify later.
How to write a good definition of done
- Make it measurable. Prefer "all tests in
auth/pass" over "auth works." - Give the agent a way to check it. A criterion the agent can't observe is useless: wire up the test command, the score tool, or the browser check.
- Set a turn cap. "Stop after 5 tries" bounds cost and stops an agent from grinding forever on an impossible goal.
- Encode the verification once. Put your review steps in a reusable skill so the same check runs every time, not just when you remember to ask.
From a single goal to a work-loop
One goal drives one loop. A stack of goals (each with its own definition of done, ordered by dependency) is a work-loop. That's Aura Crew: every task carries a goal, agents work them in order, and nothing merges until each goal is proven. The same goal ledger backs the CLI (aura loop run) and chat (/loop), so "define done, then prove it" is one consistent mechanism whether you're driving one agent or a fleet. See how goals connect to proof in proving an AI code change.
What is a definition of done for a coding agent?
A condition the agent cannot argue with — a command that exits zero, a test that passes, a metric over a threshold. It is written before the loop starts and evaluated by something other than the model, so "done" is observed rather than claimed.
What is a goal-based agent loop?
A loop that iterates until a stated success criterion is met, rather than until a turn ends or a timer expires. It suits work with a checkable outcome — make this suite pass, get this benchmark under 200 ms — and suits open-ended refactors badly.
Why do coding agents stop before the work is finished?
Because the stop condition is usually the model’s own judgement, and a model that has produced plausible code reads it as complete. Replacing self-assessment with an external check — the test command, the type-checker, a review pass — is the whole fix.
How do you stop an agent loop from running forever?
Pair the success condition with a failure condition. Cap iterations, cap tokens, and stop on no-progress: if two consecutive cycles produce the same failing output, the loop is stuck and more cycles will not unstick it.
Aura Crew vs Claude Code Loops: the autonomous work-loop, compared
Claude Code defines four loop types — turn-based, goal, time, and proactive. Aura Crew is the same idea productized: a dependency-ordered work-loop with proof, collision-safety, and any agent. Full comparison.
Autonomous coding agent loops, explained: turn-based, goal, time, and proactive
A coding agent loop is an agent repeating cycles of work until a stop condition is met. The four types explained — turn-based, goal-based, time-based, proactive — with when to use each and how to keep quality high.
How to run multiple coding agents in parallel without merge conflicts
Running several AI coding agents at once collides on shared files. The fix: a worktree per agent, a live team radar, and soft-to-hard zone claims so parallel agents never touch the same symbol. How Aura Crew does it.
How to prove an AI code change did what you asked
AI writes plausible code that quietly does the wrong thing. Proving a change means tying the commit to the goal it was meant to deliver and recording a verdict — verified, partial, or not wired — you can audit. How it works.