Stop staring at every step of the Agent: Loops and Graphs let you approve only the final step
Andrej Karpathy's free two-hour course walks through agents from Prompts to Loops. Hanako's hands-on article breaks down Loops and Graphs: why the check matters more than the output, why confidence should not be a gate, and how to put a human at the final node.
Karpathy spent 8 years at OpenAI and Tesla. Last week he compressed this experience into a free two-hour lecture, with the route: Prompts → Agents → Harness → Graphs → Loops.
Solen says in a tweet that some people spend $15k on a bootcamp and may not learn as much as they would from these two hours.
If you can't spare two hours right now, don't let it disappear from your timeline. Start by reading Hanako's article; it answers a concrete question: how to let the agent finish the work itself while you approve only the last step. Here, agent means an AI program that can call tools, edit code, and run tests on its own.
Hanako opens with a judgment: you check every step of the agent not because you want to, but because nothing else is checking. To get out of the chair, you need two things; most people have built only one of them.
Loop: a check that can fail
A loop makes a unit of work become correct without you watching. A graph decides which units of work exist.
A loop has four parts: produce, check, correct, repeat until green. The check is the whole point. Without something that can fail, you're just using a scheduler. Write the check first, and write it so a program can judge it:
GREEN: test suite exits 0GREEN: every claim carries a source lineGREEN: diff touches only files in the planNOT A CHECK: output looks goodNOT A CHECK: model says it's confidentNOT A CHECK: no errors were raised
The last one is the biggest trap. No errors does not equal correct. A system can, with clean logs, confidently repeat the same mistake until the budget burns out.
The bottleneck of a loop is this: it can only make one unit better. It cannot decide which units exist, nor the order. So you may have a powerful agent running the wrong three steps, in the wrong order. Every step is correct, yet the result is still slow and still wrong. The problem is one layer up.
Graph: deciding which work exists
A graph is the shape of the work: what runs, what runs in parallel, what waits, what doesn't run at all, and where results go back to. A node is a bounded unit of work: one input, one output. An edge is a dependency: this node's output feeds that node's input.
The most common mistake is treating then as a dependency. There is no edge between summarize the file and check the weather; weather does not consume the summary. They are two independent nodes that are merely strung together by a linear script. Ask of every arrow: does the next step read the previous step's output? If you cannot name the variable crossing over, the edge does not exist. Most chains have two or three such arrows; finding them is usually the biggest speedup.
There are four kinds of nodes: splitter, worker, code node, gate. A splitter divides the work and determines everything downstream. Split by folder, and four workers will examine the same batch of files; split by impact scope, and each worker sees something different. A worker handles one unit from a single perspective, with its own independent context. Code node is the one many people forget: merging, sorting, deduplicating, and comparing do not need a model. If describing a transformation does not require judge, decide, assess, or summarize, it is code. Using a model instead adds cost, latency, and variance to a step that does not need reasoning. Every edge being an agent graph is like paying rent on your own wiring.
Loops live inside nodes; Graphs live between nodes. A loop without a graph is a very good step; a graph without a loop will produce a pile of unverified things in parallel.
Two back-edges
A graph needs two back-edges. The short one is the correction edge: a gate sends a unit back to the step that produced it, fixing the current round. The long one is the learning edge: an accepted result becomes a constraint that goes back to the splitter, fixing every future round. Most people build only the first. So the system runs fast but never gets smarter.
Return the unit, not the whole batch
If one of four slices fails and you send the whole batch back, the three correct ones will be rewritten too. One failure becomes four uncertainties. When returning, include the unit, verdict, reason, evidence, and scope. Scope matters most; without it, a unit will casually modify nearby files too. If it still fails after three corrections, the problem is in the plan, not the loop.
Gates look at impact scope, not confidence
Confidence is the variable the model itself can influence, so it is the weakest. Order by recovery cost after a mistake: reversible and isolated first; reversible but broad-impact ones use deterministic checks and trajectory gates; hard-to-reverse ones simply stay off, no matter how high the score.
The order in which a gate reads evidence: deterministic results, the current round's trajectory, the node's historical rollback rate, and the model's own judgment. The model's judgment comes last.
Where to start
Pick something you do repeatedly. Draw the splitter, lanes, merge, a gate, and a back-edge. Build the gate first, then the lanes, and finally the learning edge. Put the human at only one point: the highest-consequence, hardest-to-reverse position. Approve the merge, choose which fixes go live, and do not review intermediate outputs. Once a human stands in the middle of the graph, they become the slowest node.
Hanako leaves three lines at the end: measure the path, not just the answer it lands on. A verdict that does not change the next step is just a report. Any failure you do not turn into a permanent constraint will be seen again.
Most people will keep tuning the same loop and call it a system. Those who draw the graph will stand to the side and watch a fleet of agents run.
The full course and templates are at agent-layers.vercel.app; the original article is at x.com/i/article/2091485629452304385.
发布时间: 2026-11-21 06:53