← All courses

A Hands-On Course · 8 lessons

Loop Engineering

Designing, controlling, and terminating the loops agents run in — so they converge on the goal instead of spinning, stalling, or burning budget.

Short lessons (~5–8 min each), each with one tangible win and a retrieval-practice quiz. Built for engineers who already use AI coding tools and want the non-obvious mechanics.

Grounded in the agentpatterns.ai corpus (CC BY 4.0). Keep the Glossary open as you go.

Part 1 · A Diagnostic Vocabulary

1 The Three Loops An agent session looks like one stream of activity — until you slice it into three loops and the symptom in the trace tells you which one to fix.

Part 2 · Strategy

2 Loop Strategy & Autonomy Two dials decide a loop's character: how much context it carries between iterations, and how much rope you hand it. Set both on purpose, not by habit. 3 Loop Structure & Orchestration A bare while True begs the model to skip the step that matters. Wrap the loop from the outside so the critical work happens whether the agent remembers it or not.

Part 3 · Stopping Well

4 Termination & Convergence Detection "It looks good enough" is not a stopping criterion. Replace the gut-feel halt with three signals you can measure across passes. 5 Go / No-Go — When a Loop Earns Its Cost A loop is not free iteration. It is a fixed setup cost plus per-turn waste — and it pays back only when four conditions all hold and the budget is bounded by one primitive that actually fires.

Part 4 · Safety & Improvement

6 Runaway Guardrails & Stuck-Loop Recovery A stuck agent is a fixed point in its own policy. Break it with the cheapest perturbation that works — then cap the recovery so it can't loop on itself. 7 Improvement & Flywheel Loops The inner loop converges one run. The outer loop makes the next run start smarter — if you wire the human's verdicts back into the rules.

Capstone

8 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.