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.
An autonomous coding agent loop is an agent that repeats cycles of work (gather context, act, verify) until a stop condition is met, instead of answering a single prompt and stopping. The idea behind "designing loops instead of prompting" is that agents do better when they can iterate against a clear goal. There are four common loop types, distinguished by how they're triggered and how they're stopped. Not every task needs a complex loop: start with the simplest one that fits.
1. Turn-based loop
Triggered by a prompt; stops when the agent judges the task complete. Every prompt you send starts a manual loop where you direct each turn: the agent gathers context, takes action, checks its work, and responds, then you review and write the next prompt. This is the plain "agentic loop." Best for shorter, one-off tasks. You improve it by writing specific prompts and encoding your review steps as a reusable verification skill so the agent can check more of its own work.
2. Goal-based loop
Triggered manually; stops when the goal is achieved or a turn cap is reached. When one turn isn't enough, you define what "done" looks like: for example, "get the homepage Lighthouse score to 90 or above, stop after 5 tries." Each time the agent tries to stop, an evaluator checks your condition and sends it back to work until the goal is met or the cap is hit. Deterministic criteria (tests passing, a score threshold) work best, because the agent doesn't have to guess what "good enough" means. This is the rung where a real proof of the goal matters most.
3. Time-based loop
Triggered on an interval; stops when you cancel or the work completes. Some work is recurring: the task is the same and only the inputs change (summarize the standup channel each morning), or it depends on an external system you poll and react to (a PR that may get review comments or fail CI). A time-based loop re-runs a prompt on a schedule. Run it locally and it stops when you close your machine; move it to the cloud and it keeps going. Prefer longer intervals, or event triggers, over tight polling.
4. Proactive loop
Triggered by an event or schedule with no human in real time; each task exits when its goal is met, and the routine runs until you turn it off. This composes the others: a schedule that watches for new work, a goal that defines done, a verification skill, a second agent that reviews with fresh context, and an autonomy setting so it doesn't stop to ask permission. Best for recurring streams of well-defined work: bug reports, issue triage, migrations, dependency upgrades. This is the most powerful and the most dangerous rung, because it can spawn many agents at once; pilot on a small slice before a large run.
Choosing a loop
| Loop | You hand off | Use it when |
|---|---|---|
| Turn-based | The check | You're exploring or deciding |
| Goal-based | The stop condition | You know what done looks like |
| Time-based | The trigger | The work arrives on a schedule |
| Proactive | The whole prompt | The work is recurring and well-defined |
Keeping quality high in a loop
The output of a loop is only as good as the system around it. Keep the codebase clean so the agent follows existing patterns; give it a way to verify its own work; make docs easy to reach; and use a second agent with fresh context for code review, because it's less biased than the agent that wrote the change. When one result misses the bar, don't just fix that instance: encode the lesson so every future iteration inherits it. To manage tokens, choose the smallest primitive and model that fit, define clear stop criteria, and pilot before a large run.
Where an autonomous work-loop platform fits
These loop types are single-agent primitives. When you want them composed across many agents on one history (in dependency order, collision-safe, with a verdict on every change) that's an autonomous work-loop platform like Aura Crew. It reads the same ready-work view whether you drive it from the CLI (aura loop run) or from chat (/loop), and gates every merge on a proof of the goal. See also how the work-loop harnesses compare.
What is an agent loop in AI coding?
An agent loop is a coding agent repeating a cycle — read the state, decide, edit, check the result — until a stop condition is met. The loop is what separates an agent from a single completion: nobody types the next prompt, the previous result becomes it.
What are the four types of coding agent loop?
Turn-based loops stop when the user replies. Goal-based loops run until a success criterion is satisfied. Time-based loops run for a fixed budget of minutes or tokens. Proactive loops start themselves from an external trigger such as a failing build or a new issue.
How does a coding agent know when to stop?
By a stop condition you supply. The reliable ones are machine-checkable: a passing test suite, a clean type-check, a score above a threshold. Asking the model to judge its own completion is the common failure — it stops when it feels finished, which is earlier than done.
What is the difference between a turn-based and a goal-based agent loop?
A turn-based loop returns control after each cycle, so a person is the stop condition. A goal-based loop keeps going without asking, and needs a definition of done written down in advance. Turn-based is safer and slower; goal-based is the one that runs while you sleep.
Is it safe to run a coding agent loop unattended?
Only with a bounded blast radius. In practice that means an isolated worktree or branch, a token or wall-clock ceiling, no credentials it does not need, and a record of every change it made. Unattended is a property of the harness, not of the model.
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.
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.
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.
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.