Understanding Loop Engineering Through 16 Humorous Illustrations
The article explains the evolution from Prompt to Loop Engineering, outlines the three‑layer nested loop model, details core components such as Spec and Eval, presents production‑grade design patterns, risk controls, and practical steps for building autonomous AI‑driven development loops.
1. Origin of Loop Engineering: From Prompt to Loop
Between 2025‑2026 the AI engineering workflow shifted through three stages: Prompt Engineering – you write instructions and the model outputs, often requiring manual hand‑over; Context/Harness Engineering – reusable system assets replace simple chat context; Loop Engineering – a closed‑loop system that automatically discovers, plans, executes, verifies, and iterates until a stop condition is met.
Andrew Ng (2026) described this as “three nested loops of different speeds,” noting that loops let coding agents operate unattended while humans retain strategic and contextual advantages. Tool teams also acknowledge that once loops become the system skeleton, the scarce skill moves from writing prompts to defining Done criteria and verifiers.
2. What Loop Engineering Is
One‑sentence essence: Loop Engineering = designing the track and closed‑loop mechanism for an agent, specifying what happens between tool calls, how self‑checks occur, and when to stop, thereby replacing manual “press‑enter” steps with an automated workflow.
The typical formulation is “discover → plan → execute → verify → repeat until conditions are satisfied.” The verifier, not the generator, determines loop value; a weak verifier yields costly garbage, while a strong verifier ensures convergence.
3. Core Principle: Three‑Layer Nested Loops (Ng’s Model)
3.1 Agentic Coding Loop (inner, minute‑level)
Who runs it: AI coding agent
What it does: repeatedly
write code → run tests → discover defects → fix → retestWhen it stops: when the evaluation confirms “bug‑free and spec‑compliant” (or when max rounds/budget limits are hit)
Ng calls this a “fast inner loop” that lets AI iterate without human intervention.
3.2 Developer Feedback Loop (middle, tens of minutes to hours)
Who runs it: human developers (product translators, quality judges)
What it does: review outcomes, adjust specifications based on real‑world usage (UI layout, interaction flow, functional boundaries, difficulty curve, etc.)
Key point: users often see mismatches between delivered results and initial expectations, so new insights must be fed back into the system.
This layer injects “context advantage” rather than mystical taste, aligning with Ng’s view that humans supply missing user‑ and scenario‑level information.
3.3 External Feedback Loop (outer, days to weeks)
Who decides: real world – users, testers, data, competitors
What it does: collect feedback (alpha, A/B tests, production data, user opinions, competitor analysis) and decide direction, next features, or strategy adjustments.
Relation to inner loops: strategic signals flow back to the middle layer’s spec, driving the coding agent.
The three layers together address implementation correctness, spec‑to‑vision translation, and strategic direction.
4. Two Pillars: Spec and Eval
4.1 Spec – defining “what to do”
Not a vague goal but an executable product requirement (features, interactions, constraints).
Iteratively refined through developer feedback loops.
4.2 Eval – defining “how to know it’s done”
Implemented as runnable judgments: test suites, quality rubrics, tool‑call correctness.
Without Eval, loops may run many rounds without converging, becoming expensive “slop machines.”
When agents repeatedly fail on similar problems, new Eval assets are created to lock down the failure mode.
5. Production‑Grade Implementation: Loop Building Blocks
Heartbeat (trigger): schedule or event‑based start (cron, webhook, etc.).
Worktrees (workspace isolation): prevent file‑write conflicts during parallel execution.
Skills (knowledge assets): codify project background, conventions, and known pitfalls for reuse.
Connectors / MCP (tool layer): enable actions such as GitHub PRs, ticket updates, messaging, data queries, test runs.
Sub‑agents / Maker‑Checker: separate writing agent from verifier to avoid self‑validation.
State / Spine (persistent progress): store run state on disk so loops can resume across executions.
The structure is often summarized as “heartbeat + multiple components + persistent spine,” with the spine being the most commonly omitted piece.
6. Methodology: Common Patterns and Design Choices
6.1 Typical Loop Patterns
Retry Loop – repeat on pass/fail (e.g., test failure).
Plan‑Execute‑Verify – plan complex tasks then validate stepwise.
Explore‑Narrow – broad exploration followed by convergence (requires strong verifier).
Human‑in‑the‑Loop – manual confirmation at high‑risk nodes.
Lifecycle Loop – long‑running, continuous monitoring and retrospection.
Selection hinges on the signal used to judge correctness and the definition of completion.
6.2 Open vs Closed Design (exploration vs convergence)
If Done is loosely defined, loops run fast but fail to converge.
If Done is strict, loops converge within budget to a satisfactory solution (ref:6).
Thus the verifier is more than a simple test; it underpins the loop’s value.
7. Practical Rollout
7.1 Minimum Viable Loop (MVP)
Identify a repeatable task with automatic failure detection (tests, lint, type‑check, build).
Manually run once to calibrate spec, environment, and gates.
Encode project knowledge as a skill to avoid re‑explaining each round.
Create a state/progress spine for continuity.
Enforce hard gates: reject submissions failing tests/type‑check/build.
Add heartbeat for timed or event triggers.
Use worktree isolation for parallelism.
Separate maker and checker agents.
Post‑launch: budget limits, logging, audit, and permission isolation.
7.2 Risk Controls
Weak verifier → costly silent errors.
Unclear stop condition → token/cost blow‑up, overnight retries.
Parallel conflicts → workspace clashes.
Missing permission boundaries → high‑risk unattended operations.
Production systems therefore impose ceilings (max rounds, time, budget), approval gates for risky actions, audit logs with traceability, sandbox isolation with least‑privilege, and circuit‑breaker style failure throttling.
8. How Loop Engineering Shifts Roles
According to Ng’s framework, engineers move from “QA/execution” toward “product vision, spec translation, and acceptance/direction correction.” The irreplaceable human contributions become:
Intent: defining what is wanted and verifiable.
Accountability: owning the final delivery.
Context advantage: supplying user‑ and scenario‑level knowledge the AI lacks.
9. Summary Model
Prompt: you manually operate each dialogue step.
Loop: you design a system where the agent repeatedly runs “discover‑plan‑execute‑verify” while humans intervene at slower loops for direction and acceptance.
Value lever: strengthening verifier and stop conditions so loops converge, remain controllable, and are auditable.
Engineering essentials: heartbeat, worktrees, skills, connectors, maker‑checker, spine.
Three‑layer nesting: coding (minutes), developer feedback (hours), external feedback (days‑weeks) jointly determine success.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Software Engineering 3.0 Era
With large models (LLMs) reshaping countless industries, software engineering is leading the charge into the Software Engineering 3.0 era—model-driven development and operations. This account focuses on the new paradigms, theories, and methods of SE 3.0, and showcases its tools and practices.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
