Lesson 1 of 6
How a coding agent works
7 min read
You type 'fix the failing test' and walk away. A minute later it's green. Between those two moments, the agent did five things over and over. What were they?
One prompt, many turns
A coding agent isn't a single call to a model. It's a loop. You give it a goal — not a script of steps — and it works toward that goal one turn at a time: read some code, decide what to change, make the change, run a tool to check itself, look at the result, and go again. It keeps looping until the goal is met or it runs out of road.
A coding agent is a model wrapped in a loop with tools. Give it a goal and it plans, acts, and observes — over and over. That loop is what makes it an agent, not just a chatbot.
The loop reacts
The power isn't any single step — it's that the agent reacts to what it observes. The first edit didn't fully work: a test still failed on a blank input. So the agent didn't stop — it read the failure, re-planned, and tried again. That feedback loop, running against real tools, is why an agent can finish a job a one-shot answer can't.
Because it observes the result of each action, the agent can course-correct. A failing test isn't the end — it's the next turn's input.
This is why coding agents feel slow but thorough: each loop is a real round-trip — read a file, run the tests, look at the output. You're watching it work, not just type.
The loop, in five moves
- —Read — index the repo so it knows what's there.
- —Plan — decide the change that moves toward the goal.
- —Edit — write the change to the files.
- —Run + observe — call a tool (tests, lint, build) and react to the result.
An agent edits a file, runs the tests, and one fails. What does a coding-agent loop do next?
Continue in the app
Take the whole How AI Coding Agents Work course — tracked
Get your personalized path, progress and streaks in the app — this lesson and every next one, in order.