Capstone

Loop Engineering · ~8 min

The Loop Engineering Decision Table

Eight lessons collapse into one reflex: read the loop pathology in front of you, then reach for the single lever that fixes that layer — and never a bigger model first.

Why this, for you: a stuck agent presents as one vague feeling — "it's being weird." That feeling is useless. The table below converts the symptom you're actually staring at into the named layer that broke and the one move that addresses it, so your next action is specific instead of a model swap and a shrug.

The through-line of the whole course: a loop is a cost you pay to remove a human from one seat — grading, initiating, or harness-tweaking. Earn that seat before you automate it, gate it before you trust it, and cap it before you let it run alone.

1 Symptom → move

Symptom you're staring atMoveLesson
"It looks stuck" but you can't say whyName the loop first — tool, verification, or convergence. Each has a distinct trace signature and its own fix; don't reach for the nearest interventionL1
Deciding what context to carry across iterationsPick accumulated vs fresh per loop; autonomy is a spectrum and Ralph's fresh-context reset is its cheap brute-force extremeL2
The loop is an ad-hoc while TrueGive it a structured body — middleware / ReAct / plan-first — so each iteration has a shape, not bare retryL3
The loop keeps grinding on work already doneDetect convergence explicitly — repeated states, diminishing diffs — instead of trusting the model's own "done"L4
"Should I automate this as a loop at all?"Run the Go/No-Go gate — cadence, objective verification, absorbable budget, real tooling must all holdL5
One turn burns millions of tokens with no progressCap iterations, wall-clock, and spend; detect the stuck loop and break out with a recovery moveL6
The system repeats the same mistakes run after runClose the outer loop — feed outcomes and human checkpoints back into rules so it improves between runsL7

2 The one rule under all of it

A loop carries fixed setup cost — a verifier, a scheduler, a state file, project-knowledge skills — plus per-iteration waste from re-reads and retries. It pays back only when the same task shape recurs and "done" is objectively checkable. Fail either and a single prompt-driven session is cheaper forever — no number of iterations fixes the inequality.

The causal mechanism is bottleneck migration: the inner agent loop produces output faster than a human can prompt the next task, so the human becomes the throughput ceiling. Each outer loop you stack removes one seat the human used to occupy — Loop 2 (verification) replaces human grading, Loop 3 (event-driven) replaces human initiation, Loop 4 (hill-climbing) replaces human harness-tweaking. LangChain calls Loop 4 "arguably most important": its return arrow doesn't loop back to the top, it reaches inside and updates the agent loop directly, so each outer cycle makes the inner loops more effective. That's the whole arc — diagnose the layer (L1), choose its context and structure (L2–L3), stop it honestly (L4), and only stack outer seats once the gate clears (L5) with caps holding the floor (L6) and a flywheel closing the top (L7).

Most loops don't earn their cost

Every lesson had a backfire box, and they rhyme. Subjective verification — when "done" is taste — leaves the maker grading its own homework and quality drifts down. A saturated reviewer caps effective throughput no matter how many agents you run; the queue gets longer, not the team faster. And a hill-climbing loop trained on stale traces silently encodes yesterday's assumptions. Bui et al. measured the tax across 567 Claude Code PRs: 83.8% merged, but only 54.9% without modification — ~45% of "automated" output still consumed reviewer time. Stack a loop only where the structure earns it.

↪ Your win: a loop-engineering reflex

Mixed review — the decision table, then a spaced recall

Question 1The course's through-line is that a loop earns its cost only when…

Question 2When the agent "looks stuck" but you can't say why, the first move is to…

Question 3A single turn burning millions of tokens with no progress is a runaway you fix by…

Question 4To stop a loop grinding on work that's already done, you should…

Question 5 · spaced recall from an earlier lessonA spinning inner tool loop and tests that stay red across turns are…

You finished the course. Ask me to run the decision table against a real loop of yours — diagnose the failing layer, score it through the Go/No-Go gate, draft the caps and recovery move, or sketch the flywheel that closes the outer loop. Or revisit any lesson; the layers compound when you stack them deliberately.
✎ Feedback