Ask a plain chatbot to fix a bug and it will describe a plausible-sounding fix in a reply. Ask a coding agent the same question and it opens the file, reads the actual function, runs the test suite, reads the failure, edits the code, runs the tests again, and only then tells you it's done — or that it isn't, and why. The difference isn't the underlying model. It's that one of them is a single text generation, and the other is a loop.
A single model call isn’t enough
A language model, by itself, is a function: text goes in, text comes out. It has no memory of your filesystem, no way to know what's actually running on a server, and no way to confirm that the code it just described compiles. Everything it says about your systems is an educated guess based on patterns, not an observation. That's fine for brainstorming or explaining a concept. It's not fine for making a change to something real, because a confident guess that's wrong looks identical to a correct answer right up until it breaks something.
What turns that single function call into something that can actually do engineering work is wiring it up to tools — and running it in a loop where each tool result feeds back in as new input before the next decision gets made.
The loop: goal, plan, tool call, observe, repeat
Strip away the branding and every agent framework is running some version of the same cycle. It reads the current goal and whatever context it's gathered so far, decides on one next concrete action, performs that action through a tool, and then reads the real result of that action before deciding what to do next. It keeps repeating that cycle — not a fixed number of times, but until the model itself judges the goal met — and then it stops.
The loop is why an agent can recover from being wrong. If the first plan doesn’t pan out — a file isn’t where it expected, a command fails, a test still doesn’t pass — that failure becomes the next input, and the model re-plans around it. A single text generation can’t do that, because it never finds out it was wrong in the first place.
Why tools, and not just better prompts
It's tempting to think a good enough prompt could get a model to just know the right answer without touching anything. It can't, for the same reason a senior engineer doesn't diagnose a production incident purely from memory: the actual state of a real system — the exact contents of a config file, the current value of a log line, whether a service is actually listening on a port right now — isn't something a model can reliably infer. It has to go look.
So an agent is given a small set of concrete tools: read a file, write a file, list a directory, run a shell command, search across a codebase or a set of logs. Each one returns real, current, ground-truth information, and each tool call becomes a checkpoint where the model's internal guess gets corrected against reality. The tools aren't an add-on bolted onto a chatbot — they're the entire reason an agent can be trusted with work that matters.
State, context, and why agents keep re-reading their own work
A model has no persistent memory between calls. Everything it “knows” at any point in the loop is whatever has been fed back into it as context — the original goal, every tool result so far, its own prior reasoning. This is why a well-built agent re-reads a file after editing it rather than assuming the edit landed exactly as intended, and why it re-runs a check after a fix rather than declaring victory the moment the edit tool returns success. The edit tool succeeding only means the write happened; it says nothing about whether the result is correct.
Where it actually ends: the verification step
The loop doesn’t stop when an action is performed. It stops when the model has evidence the goal is actually met — a test passes, a value matches what was expected, a service responds the way it should. That verification step is the single most important part of the whole cycle, and it's the part that's easiest to skip under time pressure. An agent (or a person directing one) that treats “I made the change” as equivalent to “the change works” has quietly reintroduced the exact failure mode that tools were supposed to fix.
None of this is exotic once you see it laid out. It's the same discipline a careful engineer already applies by hand — read before you write, verify before you call it done, don't trust a guess you haven't checked — just run automatically, many times a minute, with the checking built into the loop instead of left to memory.