**Understanding Loop Engineering: Failure Isolation in Goal‑Directed Controllers**
**The Scope**
This article does not argue that agent framework A is smarter than framework B, nor does it claim that a particular controller is more intelligent. Instead, it makes a narrower, testable claim: *failure isolation is a real, measurable architectural property*. The central question is whether a system can stop a single failure from halting all independent work.
**It Is a Pattern, Not a Product**
Loop engineering is a design pattern, not a specific library or framework. It means replacing a single, large prompt and a linear execution flow with an iterative system that observes state, acts, and moves toward a goal. The pattern is model‑agnostic: it applies whether the decision step is implemented with hard‑coded rules or a large language model.
**Built for Verification**
To prove the architectural claim rather than rely on intuition, the controller below is deliberately minimal and deterministic. It contains no LLM calls and no external dependencies. Its purpose is to demonstrate that a goal‑directed control loop can isolate failures to specific branches while a linear pipeline cannot.
**Measurable Failure Isolation**
In a benchmark of 300 random seeds, the goal‑directed controller completed a mean of 3.3 out of 10.3 independent branches, compared to 0.4 for a linear baseline. That is a meaningful architectural difference: the controller converts catastrophic, all‑or‑nothing failures into partial, isolated ones.
—
### The Pipeline That Stopped for No Reason
A few months ago, a task‑processing pipeline collapsed at step three of forty. A missing configuration value blocked everything downstream, including work that was entirely unrelated. The problem was not the prompt or the model; it was the control flow. The system had no mechanism to skip a broken branch and continue processing the rest.
This is the layer above the prompt: the state manager that decides what to do next after a step succeeds, fails, or gets stuck. In AI engineering circles, this is often called *loop engineering*.
—
### What “Loop Engineering” Means
The term was popularized by Addy Osmani in June 2026, building on earlier work by Peter Steinberger and Boris Cherny. It sits above *harness engineering* and complements prompt, context, and memory engineering. Other practitioners have described similar ideas, such as the “Ralph technique,” which predates the current discussion and influenced the pattern.
In this article, *loop engineering* refers specifically to the architectural pattern of replacing a monolithic prompt with a stateful, iterative control loop. The concrete implementation below is only one example of that pattern.
—
### Why This Is Not About LLMs
Every explainer of loop engineering seems to assume an LLM at the center of the loop. That assumption makes sense for products like Claude Code, but it creates a problem for verification. If results depend entirely on model behavior, you can never isolate the effect of control‑flow design.
To prove the architecture itself, the controller below uses plain Python rules instead of LLM calls. It is deterministic, has zero external dependencies, and introduces no variance between runs. If the architecture offers an advantage, it should appear even when an if‑statement decides each step.
—
### What This Article Does and Does Not Compare
This is **not** a benchmark of agent frameworks, nor is it a comparison of reasoning quality. It does not compare LangGraph, CrewAI, or AutoGen. It compares a single architectural property: what happens when a task cannot proceed?
A linear pipeline stops at the first unresolved obstacle. A goal‑directed controller reroutes around blocked branches and keeps working on the rest. That is the only claim.
—
### The Architecture: A State Machine, Not a Sequence
The system consists of an environment (a directed acyclic graph of tasks) and a controller (the logic that processes tasks each iteration). Tasks move through a shared state machine on every iteration until the entire graph reaches a terminal state.
The key difference from a linear pipeline is that tasks are evaluated independently on every iteration. Nothing is strictly sequential. The controller must distinguish between a resource that is “still resolving” and one that is “never going to resolve.” Getting this wrong causes false deadlock detection, as the author discovered while validating the benchmark.
—
### The Goal‑Directed Controller: One Concrete Implementation
The controller implements a simple rule: on each iteration, every task in an actionable state attempts to execute. If it needs a resource or a decision, the controller checks availability:
– **RESOLVED** → proceed
– **PENDING** → retry next iteration
– **MISSING** → mark as permanently blocked
This ternary signaling prevents premature termination and is the key to reliable failure isolation. The same control flow works whether `task.action` is a hardcoded function or an LLM call.
—
### Building an Environment Worth Testing Against
Synthetic task graphs are generated with six distinct behaviors:
1. Clean success
2. Flaky tasks (occasional failure)
3. Slow resources (delayed availability)
4. Missing resources (permanent block)
5. Answerable decisions (branching logic)
6. Unanswerable decisions (permanent block)
Roughly 25% of tasks are designed to be permanently unresolvable. This aggressive failure rate ensures the benchmark is not stacking the deck in favor of the controller.
—
### The Baseline: A Linear Executor
The baseline is a topological executor that processes tasks in dependency order, attempts each once, and stops entirely on the first unresolved obstacle. It allows no retries, no rerouting, and no partial credit. This represents the default behavior of systems without a control loop.
—
### The Bug That Nearly Invalidated the Benchmark
Early versions used a boolean return for resource checks. `False` meant both “not ready yet” and “never coming,” making it impossible to distinguish temporary blocks from permanent failures. The termination logic treated any lack of progress as a deadlock, producing false results.
Switching to a three‑state signal (RESOLVED / PENDING / MISSING) fixed the issue. The author then added regression tests and cross‑checked runs at different iteration budgets to confirm stability across 300 seeds.
—
### Sanity‑Checking the Benchmark
Before trusting the numbers, five checks were performed:
1. **Injection accuracy:** Each failure mode appeared at the intended rate.
2. **Traceability:** All downstream deadlocks could be traced to explicit injected blockers.
3. **Event proportions:** Retrieval, ask, and revise events matched expectations.
4. **Budget robustness:** Results did not change between 50 and 2,000 iterations.
5. **Stability across seeds:** 300 random seeds showed consistent patterns.
—
### The Results: What Actually Matters
Across 300 seeds, the goal‑directed controller completed a mean of 47.7% of resolvable tasks, while the linear baseline completed 2.1%. More importantly, the controller completed a mean of **3.3 out of 10.3 independent branches**, versus **0.4** for the linear baseline.
The controller is not smarter; it refuses to let one impossible task block everything else. That is the specific, verifiable contribution.
—
### What This Benchmark Does Not Show
The controller does not achieve perfect completion. Tasks with permanently missing resources or unanswerable questions remain unresolved, as they must. This is not a benchmark of reasoning quality, memory, or loop engineering as a whole. It is a targeted test of failure isolation.
—
### How to Tell If You Need This Pattern
**You probably do if:**
– One failed step stops the entire pipeline.
– Retries rerun the whole workflow instead of the affected branch.
– You cannot tell which independent tasks actually finished after a partial failure.
– Adding new work forces changes to failure handling everywhere.
**You can probably skip it if:**
– Your pipeline is fully sequential.
– Rerunning the whole job is cheap.
– Your main bottleneck is decision quality, not fault containment.
—
### Three Design Choices That Matter
1. **Never infer status from behavior.** Use explicit ternary signaling.
2. **Avoid termination heuristics based on quietness.** Track hard state instead.
3. **Isolate the reasoning step.** Keep the control loop agnostic to how decisions are made.
—
### Conclusion
This article demonstrates that a goal‑directed control loop provides measurable failure isolation compared to a linear executor. The result is not about intelligence—it is about architecture. By isolating faults to specific branches, this pattern turns catastrophic, all‑or‑nothing failures into partial, manageable ones.
The accompanying code is deterministic, dependency‑free, and fully inspectable. Whether or not you adopt this pattern, the key takeaway is simple: *how you manage state and iteration matters more than how you argue*.



