PTENES
Skip to content
TRACK 2

🔁 Loop Engineering

Before composing loops into a graph, you need to get a loop right. This learning path is about the cycle that made AI stop needing a babysitter at every step—and the four structural ways it can betray you while the dashboard stays green.

didn't pass → one more iteration passed discover plan act verify stop

What to look at: the highlighted box is verify, not “act.” Everyone focuses on getting the agent to act well; the step that determines the loop’s quality is the one that judges whether it’s good enough. And notice there are only two outcomes from “verify”: another iteration, or stop. Without the second one, the loop never ends.

3
Modules
18
Topics
~2h
Duration
Medium
Level
Learning path progress
0%0 of 18

Learning path map

Detailed content

2.1~40 min

🔁 Anatomy of a loop

The cycle of discover → plan → act → verify → stop, the stopping condition, what carries across rounds, and the types of loops.

What it is:

Find the next piece of work → plan → act → check the result → continue or stop. This is the agentic loop, and it fits on one page.

Why learn:

Because designing the cycle replaces writing prompt after prompt. You stop saying “do this” and start saying “repeat until it looks like this.”

Key concepts:

A loop is a graph with a cycle. The five steps are nodes; the transitions are edges; “stop” is the only edge that leaves the cycle.

What it is:

The rule that says when the loop is done. It could be “the test passed,” “two iterations with no improvement,” “spent X dollars,” or “a human approved it.”

Why learn:

A loop without a stop condition is not an agent; it is an open faucet. And stopping almost always needs layers: a normal criterion + a cap + a human.

Key concepts:

Stopping because of success ≠ stopping because of giving up. Both need to exist—and giving up needs to notify someone.

What it is:

With each cycle, the agent carries something: the history, what it has already tried, what it has learned. That’s the loop’s state.

Why learn:

Loading too much clogs the context window, and the agent starts getting confused by its own trail. Loading too little makes it repeat mistakes it has already made.

Key concepts:

Explicitly decide what passes between iterations — this is the seed of the state schema that Track 4 will formalize.

What it is:

Run the same prompt in a loop until the goal is reached — the most “digestible” version of loop engineering, popularized through Geoffrey Huntley’s Ralph method.

Why learn:

Because it became the face of the technique — and the simple version ended up representing the whole idea. Many people started there and evolved; many people stopped there.

Key concepts:

The simple version isn’t the wrong version; it’s the incomplete version. Real loop engineering means designing the cycle e the output test.

What it is:

Loop closed measures the result and uses that measure to correct the next iteration. Loop open just repeats, without looking at the effect.

Why learn:

Without feedback, you don’t have an agent; you have an expensive cron job. Feedback is what makes the loop converge instead of just spending.

Key concepts:

Closed = measure and correct. And the quality of the measurement becomes the ceiling for the quality of the loop — the topic of module 2.2.

What it is:

An outer loop that decides what to do and, inside each iteration, an inner loop that executes. E.g.: “for each file in the list, refactor until the tests pass.”

Why learn:

This is where a loop starts turning into a graph without you realizing it: each outer iteration is a node; the inner loop is what runs inside that node.

Key concepts:

Nested loops are the natural bridge to graphs. When the inner loops need to communicate with each other, the outer loop can no longer handle it.

View Full
2.2~40 min

🔬 The verifier is the bottleneck

The sentence that sums up the discipline: stop writing prompts; start writing verifiers. What makes a good output test, and why reviewing in the same context doesn’t count.

What it is:

The verifier is the step that decides “is it good enough yet?” It defines what the loop pursues — and therefore the quality ceiling the loop can reach.

Why learn:

A loop with a medium prompt and an excellent verifier converges on something good. A loop with an excellent prompt and a weak verifier converges on something that seems good.

Key concepts:

Invest where the bottleneck is. In practice: write the verifier before of the prompt.

What it is:

Compile → lint → automated test → another model judging → human. Each step costs more and catches a different type of error.

Why learn:

You don't choose one: you stack them. Run the cheap ones every iteration and the expensive ones only when the cheap ones pass.

Key concepts:

A deterministic verifier (test) is always better than a probabilistic verifier (model) when one exists. Having a model make the judgment is the last resort, not the first.

What it is:

When the same agent, in the same conversation, writes and then “reviews,” it almost always approves. It’s already convinced — the reasoning that produced the text is right there.

Why learn:

It’s the most common and most invisible flaw in a single loop. The report says “reviewed,” and no one reviewed anything.

Key concepts:

Review requires clean context: whoever judges the work must not see how it was done, only the result and the criterion. That’s one reason graphs exist.

What it is:

Every verifier compares the result with some reference: a passing test, an approved example, a written rule, a target number.

Why learn:

If the reference is vague (“make it good”), the verifier becomes a matter of opinion and the loop becomes luck. A concrete reference is what makes verification repeatable.

Key concepts:

Write the reference before you run it. If you can’t write it, you probably still don’t know what you want—and no loop can solve that.

What it is:

Tests that stop covering what changed, aging data, metric definitions that change behind the scenes without anyone noticing. The dashboard stays green.

Why learn:

It’s the most silent failure of all: measurement shifts from “checking reality” to “checking the paperwork” — one number checked against another number.

Key concepts:

The verifier also needs maintenance and periodic audits. Who checks the checker? Someone has to.

What it is:

Before writing the agent prompt, write down how you’ll know it got things right. Run the verifier against a deliberately bad result and see if it rejects it.

Why learn:

A verifier that never rejects anything isn’t verifying. Testing it against a known bad case is the only way to know it works.

Key concepts:

Verifier first = the same logic as writing the test before the code. And later, it becomes a at the of your graph.

View Full
2.3~40 min

💥 Where the loop breaks

Four structural failures—not bugs. Each happens with the loop working perfectly, which is why they motivate the graph.

What it is:

A loop sees only its own metric — and that’s why it will find all the ways to move this number, including those that betray its purpose.

Why learn:

This isn't a malfunction: it's the loop doing exactly what you told it to do, using a number that has silently drifted away from the reality it represented.

Key concepts:

When a measure becomes a target, it stops being a good measure. A metric on its own always ends up being gamed.

What it is:

The loop pursues a reference, but nothing inside it can ask whether the reference is right. The thermostat keeps the temperature at 20 degrees; it can’t ask itself whether 20 is the right temperature.

Why learn:

A perfectly execution-focused agent can spend months excellently optimizing the wrong thing. And no one inside the loop can tell.

Key concepts:

Questioning the goal requires someone outside of the loop—one node up, in the graph, or a human.

What it is:

The speed loop fights the quality loop; the hiring loop puts pressure on the culture loop. Like two badly configured air conditioners: one heats, the other cools, both “working.”

Why learn:

Examined on its own, each loop passes the test. The single-loop mindset has no vocabulary to describe the collision.

Key concepts:

A collision between loops only shows up when you draw the edges between them — in other words, when you turn them into a graph.

What it is:

Sensors go out of calibration, data pipelines rot, the metric definition changes behind the scenes. Verification slips from checking reality to comparing paperwork.

Why learn:

It’s the quietest failure — there’s no alarm, because the alarm depends on the same measurement that broke.

Key concepts:

Needs an external, periodic check against reality. No one watches the watcher on their own.

What it is:

In a single loop, everything happens in the same window: raw search HTML, a half-draft, old reasoning—all floating together when it's time to decide.

Why learn:

This mix is what produces the fake review in module 2.2 and makes the agent “forget” the original instruction from earlier.

Key concepts:

Clean context by role is one of the graph’s concrete, measurable benefits — it’s not rhetoric.

What it is:

A loop reads sources one at a time because a loop is, by definition, one thing after another. It has no way to open ten fronts and combine them later.

Why learn:

This is the only limit of the loop that no better prompt will fix it. And that's why it's the most honest argument in favor of the graph.

Key concepts:

Splitting into N branches and joining them (fan-out / fan-in) is a graph primitive. A loop can’t do this, no matter how well it’s written.

View Full