A deep dive into the part of agent harness engineering most tutorials skip
18 min read
1 day ago
--
Press enter or click to view image in full size
If you have written an LLM agent in the last two years, you have written something like this:
while not done:
thought, action = llm.think_and_act(history)
observation = execute(action)
history.append((thought, action, observation))Nine lines. Maybe twelve with a max_iterations guard. And every tutorial on the internet treats this as the boring scaffolding around the real magic — the prompt, the tools, the reasoning. The loop itself is presented as if it were a for i in range(10): — a structural inevitability, not a design decision.
I want to convince you that this is exactly backwards.
The loop is where most production agents fail. Not the prompt, not the tool definitions, not the model. The decision of when to stop — and what to do when you cannot tell whether to stop — is one of the deepest engineering problems in modern AI systems. It quietly touches the halting problem, optimal stopping theory, distributed systems failure modes, and prompt engineering all at once. And it deserves more than while not done.
This tutorial is for engineers who have built a basic agent and felt a vague unease…
