An agent is a loop, and the loop is what you debug
A coding agent perceives, decides, acts and observes, then repeats. Naming which of the four steps failed turns a mystery into a fix.
Written by
-
Benedikt Stemmildt Founder & Co-CEO
Published: 4 September 2026 Updated: 2 min read
I get this question in training rooms, half serious: is the coding agent thinking? It is a fair thing to ask when you watch one work, and the answer is the most useful thing you can teach a team about agents.
Four steps that repeat
An agent is a loop. That is the whole architecture. Strip the mystique and four steps repeat until the job is done.
- It perceives. It reads the current state: the files, the last command output, the error, the task.
- It decides. Given that state, it picks one next action.
- It acts. It runs the action: edits a file, runs a test, calls a tool.
- It observes. It reads what happened, and that becomes the new state.
Then it loops. Perceive, decide, act, observe, again, until a stopping condition says the task is finished or something cuts it off.
That is it. No hidden cognition, no magic. A capable model in a while loop with tools. The agents doing the most serious coding work have this shape underneath. The sophistication is in the model and the tools, not in some elaborate machine around them.
The loop is the thing you debug
This is more than trivia. When an agent goes wrong, it went wrong in one of four places, and naming which one turns a mystery into a fix.
- If it perceives badly, it is working from a stale or incomplete picture. Fix the context, not the prompt.
- If it decides badly, the model picked a poor next action. That is a model or instruction problem.
- If it acts and fails, a tool is broken, missing or wrongly defined. Fix the tool.
- If it observes badly, it cannot see the result of its own action, so it cannot correct. Give it a real signal: test output, an error, a check.
Debug the step, not the run
A team that knows the loop debugs the step. A team that does not just reruns the whole thing and hopes for a better dice roll. Only the first one gets better on purpose.
Next time your agent does something wrong, which of the four steps was it, and how would you know?
Further reading
Written by
-
Benedikt Stemmildt · Founder & Co-CEO
More on Coding agent setup
- A swarm of subagents is not throughput Coordinators that fan out to thousands of subagents measure merged pull requests, which is output. The limit on fan-out is how much a team can check well enough that what lands is what customers need.
- Skills hold what agents need to know, sub-agents do the thinking The first architecture decision in an agent setup is sorting what needs to think from what just needs to know. Skills carry static knowledge, sub-agents do dynamic work, and the split decides the cost.
- A harness is a list of things the model cannot do yet A harness is not plumbing around a model. Every component in it encodes one assumption: a thing the model cannot be trusted to do alone. Read it that way and the harness becomes a checklist.
Test the constraint in your system
The Factory Readiness Assessment connects this research to your value stream, your data, and the next decision.
Training on this topic: Agentic Engineering for Developers and QAWant to check one team first? The self-check: twelve yes or no questions, three minutes, instant result, no account. Take the self-check