Understanding Loop Engineering: From Answer to Accepted Result
Listen with Article TTS Reader
Checking for Article TTS Reader…
Suppose you ask an agent to check the stock of two products, and it looks up only one before finishing its answer. The response sounds reasonable. Half the request is still missing.
There are two different finish lines here: the agent has stopped talking, and the task has met its requirements. An application needs a way to tell them apart before it can reliably decide whether to continue.
Loop engineering is an existing practice. In his June 2026 essay, Addy Osmani described designing systems that prompt agents, check their work, and decide what happens next. He connected that discussion to work by Peter Steinberger and Boris Cherny.
This post explains one part of that broader idea: how the program around an agent checks its work, gives useful feedback, and decides when to stop. In the harness series, I examined these systems from the implementation side. Here, the aim is to make an established concept easier to understand through one small example.
The working code is in my Agent From Zero fork. The explanation below focuses on why the pieces exist; the repository contains the implementation and experiments.
Why does an agent that already has a loop need another one?
A tool-using agent can already repeat several steps: ask the model what to do, execute a requested tool, return the result, and ask the model again. That lets it look up information or perform several actions before answering.
But eventually the model decides it has enough to say. The tool loop can end even when a requirement was overlooked. Adding “please finish everything” to the prompt may help, but the model still decides when its answer is ready.
An outer controller gives the surrounding application a separate decision. After the agent returns, the controller checks the result against the task. If something is missing, it can explain the gap and start another attempt. If the check passes, it can accept the result.
The inner loop helps the agent take steps. The outer loop asks whether those steps produced an acceptable outcome.
The feedback arrow is where a person might otherwise say “you missed something.” The application can make that decision, provided we define what to check and when another attempt is allowed.
First, make “finished” concrete
I borrowed the continuous inventory example and step-by-step teaching approach from Bange's Agent From Zero series. My contribution here is a small teaching implementation and experiments in a fork of that project; the loop-engineering concept predates this article.
Suppose our task is: “Report the stock of A100 and B200.” For this exercise, the program has a fixed reference: A100 has 12 units and B200 has 5.
Our deliberately incomplete example answer is: “A100 has 12 units.” This is a scripted illustration, not a mistake observed from a real model. It makes the missing requirement easy to see.
Before asking the agent to try again, we can define a simple check: the answer must include both products, and both counts must match the reference. This check is ordinary code. There is no need to ask another model whether two numbers match.
The check also needs a clear boundary. Matching our reference proves that the report agrees with that reference. It cannot prove that the warehouse has not changed since we captured the numbers. Even this tiny example depends on choosing evidence that actually supports the claim we want to make.
Give feedback that explains what is missing
The controller can now turn the failed check into a specific instruction:
The report is missing B200. Return the complete stock report for both A100 and B200.
That gives the next attempt more direction than “continue” or “try harder.” It also preserves the original task. We still want a complete report, rather than a second answer containing only the previously missing product.
The diagram shows where the controller sits. This pseudocode shows what it carries from one attempt to the next:
task = "Report the stock of A100 and B200"
reference = {A100: 12, B200: 5}
feedback = none
repeat at most 4 times:
answer = agent.run(task, feedback)
check = verify(answer, reference)
if check is unavailable: stop as BLOCKED
if check passes: stop as ACCEPTED, with answer
feedback = check.what_is_missing
stop as INCOMPLETE
The task and reference stay fixed; only the corrective feedback changes. After an answer containing just A100, check.what_is_missing identifies B200, and the next call receives that feedback alongside the original request for both products. Returning an answer does not bypass the check, and a fourth failed attempt does not quietly count as success.
This is a sketch rather than runnable code. The implementation also handles failed calls, repeated answers, and cancellation; those details need not obscure the feedback mechanism here.
For a coding agent, the same pattern might mean running acceptance tests after a proposed change, then returning the failures as feedback. For a report-writing assistant, a check could catch missing sections, while a person reviews whether the argument makes sense. The quality of the loop depends on what its checks can establish.
Continuing is useful only if we can also stop
Without stopping rules, an outer loop can repeatedly produce the same bad answer or spend time on a task it cannot complete. Our small controller therefore distinguishes several outcomes:
| Outcome | What it means |
|---|---|
| Accepted | The result passed the check. |
| Limit reached | The allowed attempts ran out; the task remains incomplete. |
| Repeating itself | The same rejected answer appeared again. |
| Blocked | The agent or the checking process failed, so completion could not be established. |
| Cancelled | The user or application asked it to stop. |
These distinctions affect what happens next. If a check says “B200 is missing,” the agent has something to fix. If the checking service is unavailable, rewriting the answer may accomplish nothing. The controller should report the blockage without labeling the answer right or wrong, since neither conclusion has been established.
A limit of four attempts is also narrower than it sounds. Each attempt could contain several model calls or a slow tool. A turn limit alone does not cap elapsed time or spending. Similarly, our controller can check for cancellation between calls, but it cannot undo an action that already happened. Repeating a stock update could change inventory twice, which is why this example stays read-only.
What did the real-model experiments show?
I ran the same small task with Claude through Claude Code and with DeepSeek through its API. The counts were supplied in the prompt rather than fetched by a tool, so these runs exercised the controller rather than an inventory lookup. Every original model answer included both correct counts. To exercise the recovery path, I deliberately removed B200 from the first answer before the controller checked it.
Both integrations behaved as follows:
| Scenario | Result |
|---|---|
| Normal answer | Accepted on the first attempt. |
| Answer with the deliberately removed product | Rejected; the next real model call returned a complete answer and passed. |
This showed that the check, feedback, and continuation path worked with real text generation. It did not show a spontaneous model failure or establish that feedback improved the model: the original answers were already correct. The tests were text-only, with no live tool execution or inventory changes.
The companion guide contains the setup, offline tests, and recorded results. Those details are useful for reproducing the experiment, but the central observation is simple: the application made its acceptance decision separately from the model finishing an answer.
When is this worth adding?
For an occasional interactive task, one agent response followed by human review may be enough. An outer controller becomes more useful when a repeated or background task has a clear completion condition, and someone would otherwise have to keep checking the output and saying “you missed this.”
The difficult design choice is deciding what counts as adequate evidence. A passing test can support a specific requirement; it cannot establish that the entire product is good. A separate model reviewer can help with judgment, but its verdict still depends on the evidence it receives. Human specification and review remain important parts of the process.
Can one loop supervise another supervisor?
Yes. This is usually called nested or hierarchical supervision. A simple chain passes work from A to B to C. In a hierarchy, a parent can give a child a task, inspect what comes back, and request another attempt; that child can coordinate its own workers in the same way.
This pattern already appears in published systems and examples:
- LangChain's nested-supervisor guide shows a top-level supervisor calling a middle-tier agent that coordinates its own subagents. An earlier published implementation example composes supervisors directly; current guidance favors tool-wrapped subagents.
- Microsoft's Magentic-One describes a related separation: an outer loop revises the plan, while an inner loop tracks progress and assigns work. Persistent stalls send control back to replanning. These two loops belong to one orchestrator, rather than a tree of separate supervisors.
For our example, imagine expanding the request to “prepare a customer quote.” A quote supervisor could request an inventory report from an inventory supervisor, which manages a lookup agent and its tool calls:
This illustration is a conceptual extension, not a feature of our current demo. Each level answers a different question: did the lookup return useful data, is the stock report complete, and does the whole quote satisfy the customer request? An accepted stock report does not establish that the price or delivery terms are correct.
Extra layers are useful when those responsibilities genuinely differ. They also add calls and opportunities for mistakes. Child retries should draw from an overall budget rather than each level endlessly restarting the next. A child needs to return a blocker when it cannot finish, and parent cancellation must reach the work below it. Nesting delegates responsibility; it does not supply trustworthy checks or self-improvement by itself.
A stepping stone toward self-improving agents
This control pattern also provides groundwork for research on recursive self-improvement (RSI). Our inventory loop tries to produce an acceptable answer this time. A self-improvement experiment asks whether a change to the agent's instructions, tools, or workflow helps it do better on future tasks. Running more attempts does not establish that second result.
Recent work explores several ways to make that transition. RRSI searches for changes to the harness around a frozen model. Harness² retains components and lessons that guide later harness changes. These are different research approaches, not a single settled RSI design. A useful connection is the need to propose a change, test what it does, and decide what deserves reuse.
A next experiment for our example could stay small:
- Collect genuine failures across varied requests. The injected omission above tests the controller; it is not evidence that the agent needs a particular fix.
- Try one reusable instruction change. Compare it with the unchanged agent using the same model and comparable effort. Use practice requests to choose a candidate, then check it on separate requests that were not used to tune it. Record regressions and cost as well as wins.
- Keep adoption separate from task completion. A person approves whether the change becomes the next version. Keep acceptance checks and permission settings outside the agent's editable scope, and preserve the previous version so it can be restored.
That would test a modest question: does retaining a change help beyond the task that suggested it? It would not yet demonstrate an agent improving its own ability to improve.
Whether these research directions eventually converge on a common design remains open. Clear goals, comparable experiments, trustworthy checks, and reversible changes are useful foundations we can build now. I explore that separation between doing work, proposing improvements, and approving them in my RSI research-pipeline experiment.
For me, the useful starting point remains a bounded attempt followed by a check that can justify the next decision. Loop engineering gives us a way to organize the work; evidence must establish whether anything is actually getting better.
Read the code or go deeper
- Addy Osmani's Loop Engineering — an earlier explanation of the broader practice, published June 8, 2026.
- My Agent From Zero fork — start with the English README for the course index and runnable examples.
- The example version used for this article — controller, tests, and recorded live experiments.
- Bange's original course and upstream project — the inventory assistant and teaching approach this extension builds on. The inspected upstream version had no license declaration; the fork does not relicense it.