OneLongTail

Courses · Course 1 of 7 · Agents That Finish the Job, With Proof

Loop Engineering

Design a loop for a real recurring job: a goal with machine-checkable stop conditions, a separate checker, state on disk, budgets, an approval gate and an evidence report a human can trust in 2 minutes.

check stop whennpm test exits 0 lap 1 · exit 12 failed, loop again lap 2 · exit 0stop, log attached
An illustration of the course’s subject, not a recording.
32lessons
6modules
32open now

The idea

You stop prompting. You design what prompts for you.

Each lesson is a short simulation: you read what an agent did, a config or a tool output, make one decision and see at once whether it holds. Real terms, real commands, sourced from primary documentation.

A loop spec has seven parts

  1. Triggera schedule or a repo event starts the run
  2. Goalwhat the run is for, in one sentence
  3. Stop conditiona command that returns pass or fail
  4. Checkersomething other than the maker judges the work
  5. Stateprogress on disk, so a fresh session resumes
  6. Budgetturns, tokens, money, time
  7. Escalationthe points where a person decides

Modules · 32 of 32 lessons open, the rest are being built

01The loop and the harnessWhat a loop is, what the harness controls, and the two things every loop needs first: a stop condition a script can check, and a budget.5 lessons · 5 open
  1. 01Four loops people meanOpenTell apart execution loop, task loop (Ralph), product loop and system loop, and the human oversight loop around them.
  2. 02The harness: what runs around the modelOpenName the parts a harness controls (tools, context, permissions, checks, state) and which failure each one prevents.
  3. 03From prompting to designing the loopOpenTurn a job you prompt by hand every day into a loop spec: trigger, goal, stop condition, checker, state, budget, escalation.
  4. 04Stop conditions a machine can checkOpenReplace 'until it looks good' with conditions a script can evaluate (tests green, feature list all pass, max turns).
  5. 05Budgets: turns, tokens, money, timeOpenSet hard caps on turns and money per run, cap time from outside the run (timeout, timeout-minutes), know that token caps hold per request only, and see what a loop without caps costs overnight.
02Done means provenAgree on “done” before work starts, keep requirements as pass/fail entries, make the agent run what it built, and accept only evidence.8 lessons · 8 open
  1. 06Sprint contracts: agree on 'done' before work startsOpenHave generator and checker agree on testable criteria for a chunk of work before any code is written.
  2. 07The feature list as pass/fail JSONOpenKeep every requirement as a pass/fail entry the agent may only flip with evidence; see why JSON beats prose here.
  3. 08The verification loop: build, run, checkOpenMake the agent run the thing it built, not only read it, and feed the result into the next turn.
  4. 09Evidence, not claimsOpenRequire a reproducible artifact (test output, screenshot, trace link) for every 'done' and reject reports without one.
  5. 10A separate, skeptical checkerOpenSplit maker and checker; tune the checker to be skeptical because agents grade their own work too generously.
  6. 11Reward hacking: when 'all tests pass' liesOpenSpot special-cased tests, deleted tests and weakened assertions in an agent's green run.
  7. 12Prove the check can failOpenMutate the output on purpose and confirm the checker goes red before you trust its green.
  8. 13Right answer, wrong pathOpenRead and grade the trajectory, not just the final state: right tools, right order, no forbidden or wasteful actions on the way to a correct result.
03State that survives the runAn initializer run, progress files, commits as checkpoints, and the choice between compaction and a fresh context.5 lessons · 5 open
  1. 14The initializer runOpenUse a first session that sets up environment, feature list and progress file for every later session.
  2. 15Progress files: the spineOpenKeep what is done and what is next on disk so a fresh session resumes in one read.
  3. 16Commits as checkpointsOpenCommit after each verified step so a bad turn is one revert, not a lost night.
  4. 17Compaction or a context resetOpenChoose between summarising in place and starting a fresh agent with a structured handoff.
  5. 18One feature per sessionOpenCap each session to one feature so failures stay small and evidence stays readable.
04Building blocks of a loopTriggers, worktrees, skills, sub-agents and connectors: the parts you assemble a loop from.5 lessons · 5 open
  1. 19Triggers: schedule and eventsOpenStart runs from a schedule or a repo event with a run limit, instead of a human prompt.
  2. 20Worktrees for parallel agentsOpenGive each parallel agent its own checkout so they never overwrite each other.
  3. 21Skills: write the project knowledge down onceOpenMove repeated instructions into a skill the loop loads only when needed.
  4. 22Sub-agents: maker, checker, researcherOpenScope sub-agents so their work does not overlap and their reports come back short.
  5. 23Connectors: what the loop may touchOpenGive the loop only the tools and permissions the job needs, scoped and revocable.
05When loops go wrongPremature victory, endless loops, runs that end differently each time, and the points where the loop must hand over to a person.4 lessons · 4 open
  1. 24Premature victory and endless loopsOpenDiagnose the two classic failures from a trace and add no-progress detection plus an iteration cap.
  2. 25Same job, different endingOpenMeasure a loop over k runs, then choose pass@k or pass^k by what the job needs: pass@k when one good run out of k is enough, pass^k when every run acts on its own.
  3. 26Escalate, don't guessOpenDefine the exact points where the loop stops and hands a human a decision with evidence.
  4. 27Strip the harness when the model improvesOpenRe-test each harness part on a new model and remove the ones no longer load-bearing.
06Running loops without youApproval gates, traces, the morning report, quiet drift, and a capstone: a full loop spec for a real recurring job.5 lessons · 5 open
  1. 28Approval gates for irreversible actionsOpenPause before send, pay, delete, deploy; batch approvals so they stay fast.
  2. 29Tracing a finished runOpenCapture every LLM call, tool call, guardrail and handoff in a trace, then read a finished run's trace to find the turn where it went wrong.
  3. 30The morning reportOpenMake every loop end in one evidence report: what changed, proof, cost, open decisions.
  4. 31Quiet driftOpenCatch a loop whose pass rate slowly falls with a regression suite run on schedule.
  5. 32Capstone: design a loop for a real jobOpenWrite the full loop spec for a recurring job and run it to an evidence report.

Built on primary sources