Extrait de la leçon

Autonomous AI Coding Agent for Hours: Loop Engineering and Stop Conditions

Loop engineering: running an AI coding agent in an autonomous loop. Loop types, goal and metric, stop conditions, human escalation, generator and evaluator separation, costs of autonomy.

Loop Engineering generator and evaluator stopping conditions escalation to a human
Ce que vous apprendrez dans cette leçon
  • Design an autonomous loop with explicit stopping conditions and escalation.
  • Separate the generator and the evaluator so that one cannot deceive the other.
  • Assess your own process against the autonomy maturity ladder.

Début de la leçon

The agent that worked all night in the wrong direction

  • A goal with no clear finish line — a loop that doesn't know when to stop
  • The agent's own self-assessment as the only brake — and it fails to engage
  • No one called a human, though the moment was obvious

An agent on the night shift sounds wonderful: set the task, go to bed, wake up to a finished result. In practice it often goes differently. The agent cheerfully runs the same step again, because it doesn't remember the previous run. It decides for itself that it has succeeded — and then believes its own verdict. The stop condition is written down nowhere, and there's nothing prompting it to call a human, because the loop can't recognise the moment it's stuck. The problem isn't the model. The problem is that the loop was designed like an ordinary prompt, only set running in circles.

🤔 Myth: a loop makes the harness optional

  • 🤔 Myth: add a loop on top and you can relax about the harness
  • ✅ In reality: the harness makes a single run reliable; the loop makes continuous runs autonomous
  • 📌 Remember: a loop on top of a weak harness produces rubbish faster

Here's a trap that's easy to fall into: you stop being the person writing prompts for the agent and start designing a system that writes them for you — and it feels as though the harness you've been building since the beginning of the course now matters less. Quite the opposite. The harness makes a single run reliable. The loop makes continuous runs autonomous. If the harness is shaky, the loop simply produces rubbish faster and unsupervised — only now on an industrial scale.

The simplest possible loop

  • Goal — what the end state looks like
  • Verification method — machine-checkable
  • Stop condition — an attempt limit and a budget

Imagine you're going away for the weekend and you leave a trusted tradesperson your keys — clear the blocked gutter while I'm away. Take away any one of the three parts, and it stops being a loop. First, the goal: 'the gutter is dry after rain', not 'the tradesperson popped round and had a look'. Second, the way of checking: when you're back, hold a bucket under the downpipe for five minutes — dry means done, rather than 'the tradesperson reckons it's all sorted'. Third, the stop condition: three attempts and an agreed budget, after which they stop and ring you, rather than taking it upon themselves to redo the roof. Without any one of the three, it isn't a loop — it's a single visit that happened to be repeated a few times.

La leçon complète est réservée aux abonnés

Encore 22 diapositives dans la version complète.

La vidéo, toutes les diapositives, le résumé, les tests, le tuteur IA et l'entretien s'ouvrent après connexion et souscription à un abonnement.

Se connecter ou s'inscrire Souscrire un abonnement

Sommaire de la leçon

  1. The agent that worked all night in the wrong direction
  2. 🤔 Myth: a loop makes the harness optional
  3. The simplest possible loop
  4. A plain prompt versus a loop
  5. Four types of loops
  6. Pitfall: mixing up a time-based loop with a goal-based loop
  7. ❓ Checkpoint: does this job have an end?
  8. The six primitives of a loop
  9. The six primitives of a loop
  10. Three conditions without which an autonomous loop won't start
  11. Three things without which the agent goes blind, flatters itself and forgets everything
  12. Generator–evaluator separation: the guarantee you can't opt out of
  13. The rules of separation: someone must not take your word for it
  14. 🛠 Andrej Karpathy's autoresearch
  15. Three files, three roles
  16. The mechanics of the loop: a ratchet that only moves forward
  17. Two design decisions worth stealing
  18. The full map of a loop that can't lie to itself about success
  19. program.md — the methodology in its real form
  20. Four quiet costs of autonomy
  21. Antidotes — and Osmani's insight about two identical loops
  22. The autonomy maturity ladder
  23. End-to-end project: program.md for a payments backend
  24. How to build your first loop in a single evening
  25. From harness to loop — and beyond

Articles sur cette leçon

Toutes les leçons du cours

  1. What Is Harness Engineering? Why AI Coding Agents Fail Because of the Environment
  2. Error Accumulation in AI Agents: Why 95% Per-Step Accuracy Fails by Step 10
  3. AI Agent Reliability Metrics: MTBF, MTTR, Blast Radius and Little's Law
  4. Why AI Agents Fail in Production: Five Failure Layers and a Diagnostic Loop
  5. What an AI Agent Harness Is Made Of: Instructions, Tools, Environment, State, Feedback Loops
  6. Repository Map for AI Coding Agents: Project Structure and State Without Memory
  7. AGENTS.md Best Practices: Why a Giant Instructions File Fails and How to Build a Router
  8. AI Agent Memory Between Sessions: Session Handoff, PROGRESS.md and Bootstrap Contract
  9. feature_list.json for AI Agents: WIP=1, Feature Status and verify.sh Verification
  10. Agent Says 'Done' but the Feature Is Broken: Verification Gap and Definition of Done
  11. All Tests Pass, Feature Is Broken: E2E Tests and Architecture Rules for AI Agents
  12. AI Agent Observability: Sprint Contracts, Evaluator Rubrics and Clean Session Exit
  13. Autonomous AI Coding Agent for Hours: Loop Engineering and Stop Conditions
  14. Graph Engineering for AI Agents: When a Single Loop Is Not Enough and You Need a Task Graph
  15. Building an AI Agent Harness From Scratch: AGENTS.md, feature_list.json, verify.sh and an Autonomous Loop