← Back to Blog

The Agent Loop: Why an LLM is Not a Software Engineer

October 31, 2026 · 4 min read
The Agent Loop: Why an LLM is Not a Software Engineer - Why an LLM is not a software engineer, how the Agent Loop and tools turn text prediction into action, and why toy agents break in production.

A teenage forward arrives at the football academy with a cannon of a shot.

He can drill a ball into the top corner from thirty yards in training. But in his first match, the coach holds his head: the kid gets the ball, drops his eyes to the turf, and blasts it forward. If a defender stands in front of him, the ball hits the defender. The rebound rolls back, and the kid kicks it again. He never lifts his head, never checks the wings, and never notices the open goal.

He has a shot, but he has no game loop.

Many engineers assume a chat model and a coding agent are the same thing. That misunderstanding explains why so many AI coding setups fail on real codebases.


The Reality

An LLM on its own is a player with his eyes glued to the grass. It only predicts the next word in a sequence.

If you give it a compiler error, it will generate a plausible fix. But the model has no idea if the file exists on your drive, if the project compiles, or if its patch broke the payment gateway.

To turn a model into an agent, engineers wrap it in a control loop: the Agent Loop.

You give the model four tools:

  1. read_file: lift your head and scan the pitch.
  2. write_file: create a new file or script.
  3. edit_file: make a targeted pass into space.
  4. bash: strike the ball and look at the scoreboard.

Then the loop runs. The model examines the goal, calls a tool, waits for the operating system to respond, and reads the output. Did the test fail? The traceback feeds back into the model as an observation. The model edits the code and runs the test again. The loop turns until the scoreboard lights up green.

The Why

You can build a working coding agent in 200 lines of code. You call the model API, hook up four functions to read, write, edit, and run shell commands, and on tiny scripts, it works.

Put that 200-line agent into a production repo, and it falls apart in minutes.

Where does it break down?

Environment traps.

The first trap is output bloat. The agent runs a build command, the console dumps ten thousand lines of compiler logs, and the context window overflows. The agent goes blind and forgets the user’s prompt.

The second trap is string-matching failure. A basic agent tries to edit a function, misses a single whitespace character, and the tool fails. The agent tries the exact same edit again, fails again, and gets stuck in an infinite loop, burning through API credits in minutes.

A production agent harness differs from a toy script not by the model inside, but by its defenses: truncating outputs, diff parsing, cycle detection, and permission guards.

The Takeaway

The model supplies the reasoning, but the loop around it delivers the work: the discipline to inspect an action and adapt after a mistake.


AI specialists call it: The Agent Loop / Agent Harness / Tool Use & Action-Observation Cycle
An agent loop is a state machine built around a large language model. On each turn, the model receives system instructions, conversation history, and tool results, emitting structured tool calls. The harness executes those calls in the host environment (reading files, writing code, executing shell commands) and feeds results back to the model as observations until an exit condition is met.

💬 Have you ever worked with a developer who hit a test failure and immediately re-ran the exact same command three times without changing a line of code?

Part 1 of 10 | #CodingAgentsForHumans

Have a project in mind?

Let's talk about how we can help.

Got a project idea? →