Why These Seven

Each loop on this list was chosen to illustrate a different architectural pattern. Not because they are the most impressive or the most complex , because together they cover the full range of what loops can actually do. Build all seven and you will understand agent architecture in a practical way that no amount of reading will give you.

The loops range from quick setups to half-day builds. The order matters less than working through all of them. Each one surfaces a different class of design problem: how to define exit conditions, how to manage state, how to handle parallelism, how to make a loop that criticises its own output. Those are skills that transfer to every loop you build afterward.

A note on how to use this list: pick one and build it to completion before starting the next. A half-built loop teaches you nothing. A loop that runs and does something real teaches you the one specific thing it was designed to teach.


Loop 1 and 2: Quality Gate and Coverage Completion

The Refine Loop is the quality gate pattern. Generate output, evaluate it against explicit criteria, refine if it falls below the threshold, repeat. The exit condition is not a fixed number of iterations , it is a quality score. Apply it to blog post drafting, email writing, any text output where you can articulate a clear standard in advance.

The design challenge in Loop 1 is operationalising quality. "Good enough" is not an exit condition. A working version scores the output on specific dimensions , clarity, completeness, tone, accuracy against source material , and exits when the aggregate score crosses a defined threshold. The scoring logic is where most of the design work lives. Get it wrong and the loop runs forever or exits on the first pass regardless of quality.

The Research Loop is the coverage completion pattern. Generate search queries, retrieve results, check whether the required topics are covered, generate more queries if not, synthesise when coverage meets the threshold. Apply it to background research where you can list the required coverage areas in advance , a list of specific questions the research must answer before the loop is done. The exit condition is explicit coverage, not elapsed time or iteration count.


Loop 3: Build-Test-Fix

The Build-Test-Fix Loop is the software development pattern. Implement something, run the tests, if tests fail fix the implementation, re-run the tests, exit when they pass or when you hit the iteration cap. This is the pattern that most AI coding tools implement under the hood. Building it yourself takes a few hours and changes how you think about every AI coding tool you use afterward.

The key design decision is what counts as "tests pass." For some tasks it is a test suite with a clear pass/fail binary. For others , like generating a configuration file or writing documentation , the test is a validation function you write to check the output against your requirements. The pattern works for both; the implementation differs.

Start with a task you can verify easily: a function that should pass three specific unit tests, a JSON file that should validate against a schema, a script that should produce specific output for specific input. The verifiability is what makes the loop useful. If you cannot write a test for it, the loop cannot exit on quality , only on iteration count.


Loop 4 and 5: Extraction and Monitor

The Extraction Loop is the parsing pattern. Read a source document, extract the target fields, validate that the extracted data matches the expected schema, flag incomplete extractions, continue to the next source. Apply it to processing batches of documents , contracts, invoices, meeting notes, emails , where you need structured data out of unstructured text.

The validation step is what separates a useful extraction loop from a brittle one. A loop that extracts without checking produces silently wrong data that you do not discover until downstream. A loop that validates and flags gives you a clear record of where the source documents were ambiguous, non-standard, or simply did not contain the expected information. The flags are as useful as the successful extractions , they tell you where the source data has problems.

The Monitor Loop is the event-driven pattern. Check state, if changed process it and produce output, sleep, repeat. Apply it to watching a website, a file directory, or an API endpoint for specific changes. This is the easiest loop to set up and the easiest to verify in real time , you can watch it detect a change you deliberately made and confirm the processing worked. Start here if you have not built a loop before. The feedback cycle is short and the behaviour is immediately obvious.


Loop 6: Critique

The Critique Loop is the adversarial pattern. Produce initial output, run a critique pass against the output, revise based on the critique, stop when the critique finds no significant issues. Apply it to any generated content where quality matters: long-form writing, analysis documents, code architecture decisions, structured data outputs.

One model acting as both producer and critic is more effective than most people expect the first time they try it. The critique pass catches a different class of problem than the generation pass. Generation optimises for completing the task; critique looks for gaps, inconsistencies, and weak reasoning. The two passes together produce output that is consistently better than either produces alone.

The exit condition requires care. "No significant issues" must be operationalised. A working approach: the critique step produces a list of issues with severity scores, and the loop exits when no issue in the list exceeds a defined severity threshold. Vague exit conditions are where loops spin indefinitely. Concrete ones produce clean termination.


Loop 7: Parallel

The Parallel Loop is the fan-out pattern. Take a list of inputs, process each one in parallel, aggregate the results. Apply it to researching multiple topics at once, reviewing multiple documents, generating multiple content variations for A/B testing, or processing a large batch where sequential handling would take too long.

This loop is the most technically demanding of the seven because it requires async handling. Sequential loops are simple: one thing happens, then the next. Parallel loops require managing concurrent operations, handling partial failures gracefully, and aggregating results that arrive at different times. If you are comfortable with async code in your language of choice, this is a half-day build. If you are not, budget a full day and treat it as an opportunity to learn the pattern.

The speed advantage is the point. A task that requires processing twenty items sequentially at thirty seconds each takes ten minutes. Processing them in parallel takes thirty seconds. For research tasks, document review, or content generation at scale, that difference is the difference between a loop you actually use and one you run once and abandon.


Where to Start

For developers, start with Loop 3. The Build-Test-Fix pattern connects directly to work you are probably already doing, gives you immediate practical value, and teaches the core loop architecture in a context where the exit condition is concrete and unambiguous.

For non-developers, start with Loop 5. The Monitor Loop has the lowest technical barrier, the fastest feedback cycle, and real everyday utility. A monitoring loop that watches a news source or a competitor's job postings is useful from day one.

Loops 1, 2, and 6 require the most thought on exit conditions. Do not attempt them until you have a measurable definition of done written out before you start building. Vague exit conditions are where loops go to spin.

Loop 7 requires async knowledge. Save it for last unless you already work with concurrent code regularly.

One final note: document what you learn from each build. The patterns are transferable, but the specifics , the exact exit condition that worked, the state structure that kept things clean, the error that appeared at iteration 8 and how you handled it , those are only useful if you write them down. The notes from building these seven loops are the beginning of your own agent engineering practice.