Skip to content

AgentsMAY 21, 2026 · 3 min read

An agent is a loop that learned to stop

Strip away the frameworks and every agent is a while-loop around a model. The entire discipline of agent engineering is deciding what belongs in the loop condition.

Under every agent framework you have evaluated this year — every graph, every crew, every swarm — sits the same four lines of code:

while not done:
    thought = model(context)
    result = execute(thought.action)
    context = update(context, result)

That’s the whole genre. A model, a loop, and a mutable context. Everything else that ships in a framework — the YAML, the decorators, the orchestration diagrams that look like subway maps — is opinion about how to write update and done.

This is not a dismissal. It’s a relocation of respect. Once you see that the loop is trivial, you can see where the actual engineering lives, and it lives in the two functions the demos never show.

update is a theory of memory

The naive update appends. Result after result, the context grows like sediment, and the agent slowly buries itself in its own history. We wrote about the cure in The empty context window: summarize, externalize, keep the window for the live task. The point here is structural — update is not plumbing. It is the agent’s entire theory of what the past is for, and most agent failures that get blamed on the model are failures of this one function.

done is a theory of judgment

The loop condition looks like a boolean. It is actually the hardest open problem in the field, wearing a boolean’s clothes.

Stop too early and you ship the pathology everyone recognizes: the agent that declares victory with failing tests, the summary that says “I have successfully completed” above a stack trace. Stop too late and you get its expensive twin — the agent that gilds a finished task for forty more turns, refactoring what worked until it doesn’t.

What makes done hard is that it can’t be answered from inside the transcript. “Do I look finished?” is a question about text. “Am I finished?” is a question about the world. The gap between those two questions is where agent reliability goes to die.

So the craft is to make the world answer. Run the tests and read the exit code. Re-fetch the page and look. Diff the file you claim to have written. Every hardened agent system converges on the same move: replace self-assessment with observation, then let done be a fact instead of a feeling. The teams that do this stop asking “why does the model lie about finishing?” — a question about souls — and start asking “what observation would make finishing undeniable?”, which is a question about engineering.

The dignity of halting

There’s a reason the koan at the top of this essay says halting is also an action. In reinforcement learning terms, stop is just another arm — but it’s the arm our training pipelines are worst at rewarding. A model is graded on the helpfulness of what it produces, and stopping produces nothing gradeable. So models learn a bias the Zen tradition would recognize instantly: the compulsion to keep generating, to fill silence with tokens, because generation is the only act that has ever been praised.

Which means restraint has to come from the harness. Budgets, turn limits, escalation paths that end with the agent saying the three hardest words in the vocabulary: I am blocked. An agent that can stop cleanly — report honestly, hand back control, leave the workspace better than a crash would — is worth more in production than one that is ten points smarter and cannot.

The old models of computation had this dignity built in. A Turing machine’s halting state isn’t an admission of defeat; it’s the definition of an answer. Somewhere between theory and product we started treating termination as churn to be minimized rather than the moment the work becomes real.

Build loops that stop. Better: build loops that know why they stopped, and can say so. The intelligence in the system may come from the model, but the wisdom — such as it is — lives entirely in the loop condition.

It usually amounts to knowing the difference between “there is nothing more I can say” and “there is nothing more to do.”

Halting is also an action.