Skip to lesson
Exit
How Coding Agents Work (and Their Limits)1 / 3

1 min lesson

The loop, step by step

Connect "The loop, step by step" to the decision you would make.

Step 1 of 3

The loop, step by stepprompt → applied edit

An agent run is a loop that keeps calling the model, feeding back what each action produced, until the task is done or a stop condition trips.

Learn more

Full explanation

The Agent Loop

THE AGENT LOOP

Interactive diagram. Step through it with the Next and Previous controls below, or Tab to a region to read its detail.

diagram: flow

The whiteboard artifact: assemble, decide, act, observe, revise. The last step loops back until the task is done.

Narrate one run

Take a failing test. The harness assembles context: my prompt, the failing test, the file it imports and the project rules. The model decides the quickest check is to run the suite and emits run_terminal({ command: "npm test" }). The harness runs that for real and appends the output as the next observation. The model reads a failed assertion, revises, edits the function and calls run_terminal again. This time the observation is all green, so it declares the task done and I review the diff.

The harness is the product, not the model

Anyone can call a high-capability model's API. What makes one agent better than another on the same model is the harness: how it indexes a million-line repo, what it retrieves into a finite context, how it defines tools the model can call reliably and how it decides when to stop. When a developer asks 'which model does Cursor use,' the more interesting answer is 'here's what we do around the model.'