Agentic coding is the step past AI autocomplete and chat: you give an AI a goal — "fix the failing checkout tests," "add dark mode to settings" — and an agent plans the work, edits files, runs commands, and keeps iterating until the goal is verifiably done. The word doing the heavy lifting there is verifiably. Anyone can wire a model to a shell; the difference between a useful agent and an expensive random-walk is the loop around it.
The loop, phase by phase
Cortex's loop engine runs seven phases. Most serious agent designs converge on some version of this shape:
- Goal. Your instruction, turned into concrete success criteria — which tests must pass, what must build, what behavior must change.
- Discover. The agent explores the codebase and establishes a baseline: what already passes, what already fails. Without a baseline, an agent can't tell whether it fixed something or broke it.
- Plan. An ordered list of file edits and commands — small enough to verify, big enough to matter.
- Act. The agent executes: reading files, editing code, running shell commands with its tool set (Cortex ships 24+ tools — file ops, grep, semantic search, git, web search, MCP servers).
- Verify. The critical phase. The loop runs your real tests, linter, and build, and reads the exit codes. Success is never the model's opinion of its own diff — it's ground truth from your toolchain.
- Revise. Verification failed? The agent studies the failure output and loops back with a corrected plan.
- Review. Before declaring victory, a second model — a maker/checker pair — audits the final diff against the goal. Two different models rarely share the same blind spot.
Why "the model checks its own work" isn't enough
Language models are confident narrators. Ask one whether its patch is correct and it will usually say yes — including when the code doesn't compile. This isn't a flaw to prompt away; it's why the loop must anchor to external signals. A test suite's exit code can't be sweet-talked. That's the design principle behind the verify phase: real tests, lint, and build results — never model judgment. The maker/checker review adds a second, independent set of eyes on top, the same way human teams use code review even for senior engineers.
Budgets: why a loop can never run forever
An autonomous loop with your API key needs hard limits, enforced by the engine rather than promised by the model. Cortex enforces four independent ones:
- Iteration cap — a maximum number of loop cycles.
- Stall detection — if consecutive iterations stop making progress (the doom-loop pattern), the loop halts instead of burning tokens on repetition.
- Wall-clock limit — a time box on the whole run.
- Token and dollar budgets — actual spend tracked per model; the moment a budget is exceeded, the loop stops.
Budget enforcement is what makes it sane to combine autonomy with BYOK pricing: you get pay-per-use economics with a hard ceiling you set yourself.
Safety gates while the agent works
Between the budget layer and the verify phase sit the guardrails that govern each individual action: dangerous-command blocking (rm -rf, git push --force and friends), read-before-edit enforcement so the agent can never blindly overwrite a file it hasn't looked at, and per-tool budgets. And autonomy is a dial, not a default — in ASK mode the agent proposes every change for your approval; AUTO mode is for tasks you're happy to delegate end to end.
What this feels like in practice
You write one message describing an outcome. The agent explores, shows its plan, and gets to work — editing files, running your test suite, reading failures, fixing them. Minutes later you review a diff that already passes tests, with a second model's audit behind it. The skill you practice shifts from writing every line to specifying goals well and reviewing results — which is why picking a tool whose loop you trust matters more than picking the single smartest model. If you're evaluating options, start with the five questions that actually separate AI IDEs, or see the loop yourself: download Cortex for Windows and hand it a real task from your backlog. The docs explain every phase, mode, and budget in detail.