1. Home
  2. Library
  3. AI Tooling Crash Course for Developers
  4. Topics
  5. Loop Engineering Agent Loops

Loop Engineering — Building Agent Loops That Actually Finish

Split out 2026-09-05 from harness-engineering-vocabulary.md on the user's call: a harness is the surrounding software, a loop is the specific practice of running one agent repeatedly toward a goal, and they deserve separate bite-size docs even though a loop always runs inside some harness. Recent term, possibly short-lived, possibly a lasting category, not yet settled either way.

Not about code review/verification tooling — for that, see review-and-verification-tooling.md. This doc is about the "keep running the agent until the goal condition is met" pattern.

What it actually is

Running the same agent in a cycle — see result, decide next step, act again — until a goal condition is met, instead of one single model call. The obvious naive version: just let the model keep going in one long session. In practice this doesn't hold up past a certain amount of work, which is the actual subject of loop engineering: not "how do you make a loop" (trivial), but "how do you make a loop that reliably finishes instead of drifting or lying about being done."

See the resultDecide the next stepAct againrepeat until the goal condition is metNaive versionOne long session that keeps going.Stops holding up past some amount of work.Loop engineeringNot how to make a loop (trivial).How to make it finish, not drift or lie.See the resultDecide the next stepAct againrepeat until the goal condition is metNaive versionOne long session that keeps going.Stops holding up past some amount of work.Loop engineeringNot how to make a loop (trivial).How to make it finish, not drift or lie.
Making a loop is trivial. Making it finish is the subject.

Why plain looping fails

A source frequently misattributed on this point: it's not Anthropic's effective-harnesses-for-long-running-agents article arguing that looping alone is a core capability — that article argues close to the opposite. Direct quote: "compaction isn't sufficient. Out of the box, even a frontier coding model like Opus 4.5 running on the Claude Agent SDK in a loop across multiple context windows will fall short."

Initializer agentruns once, sets up scaffoldingclaude-progress.txtgit commit historyfeature list (JSON)Coding agenteach new session, fresh contextmakes incremental progressstate survives in plain files, not in the model's memory or a compaction summaryInitializer agentruns once, sets up scaffoldingclaude-progress.txtgit commit historyfeature list (JSON)Coding agenteach new session, fresh contextmakes incremental progressstate survives in plain files, not in themodel's memory or a compaction summary
Anthropic's proposal: externalize state, then loop with a fresh context each time.
Do a chunkof workWrite state toa progress fileRun an externalcheck (tests, verdict)pass?Stopyesno: loop again with the failure in hand✕ "I think I am done!" (self-report)the done-condition lives outside the modelDo a chunk of workWrite state to a progress fileRun an external checktests, verdictpass?yes: Stopnoloop again with thefailure in hand✕ "I think I am done!" (self-report)the done-condition lives outside the model
Explicit done-condition and an outside check, instead of trusting the agent to say it is finished.

Its actual proposal is a two-agent harness, not a single loop:

  • an Initializer Agent — runs once, first session, sets up scaffolding
  • a Coding Agent — runs in subsequent sessions, makes incremental progress against state that was externalized by the first agent

The state that survives between fresh context windows lives in plain files, not in the model's memory or an automatic compaction summary: a claude-progress.txt, git commit history, a JSON feature-completion list.

The stated reason plain loops fail isn't infrastructure, it's a specific model behavior: Claude tends to "attempt to one-shot the app" and prematurely declare completion. A loop that trusts the model's own "I'm done" is a loop that stops early on hard tasks. The fix is giving the harness an explicit, externally-checkable definition of done, so the loop can verify completion itself instead of trusting self-report.

The actionable shape

External progress file plus explicit, machine-checkable completion criteria the agent can't talk its way past. Cheap to build, no special infrastructure needed, just discipline about where state lives.

External progress filestate lives in plain files,not in the model's memory+Machine-checkable doneexplicit criteria the agentcan't talk its way pastCheap: no special infrastructure, just discipline about where state livesAlready working in this repo, unnamed:_architecture/items.json, the live store_architecture/plans/, planning recordsExternal progress filestate lives in plain files, not in themodel's memory+Machine-checkable doneexplicit criteria the agent can't talk itsway pastCheap: no special infrastructure, justdiscipline about where state livesAlready working in this repo, unnamed:_architecture/items.json, the live store_architecture/plans/, planning records
The practice predates the term. The term names something already working.

This repo already does this at two levels without having named it: _architecture/items.json's live store at the project level, and planning records under _architecture/plans/. The practice predates the term; the term is just a name for something already working here.

Open questions / weak sourcing

  • Anthropic's context-engineering article and the long-running-agents article were both fetched and quoted directly during the original research pass — high confidence on the quotes above.
  • A prior version of this research (from a secondary "dump" source) attributed "the agent loop as a core runtime capability" to that same Anthropic article — checked directly and found inaccurate, corrected above. Worth remembering that AI-search summaries sometimes misattribute a claim to a real source that actually argues something adjacent but different.
  • Whether "loop engineering" survives as a distinct named term or gets folded back into general harness/agent design is unresolved as of this writing (2026-09).
14 / 19