Glean 拾遗
Daily /2026-11-10 / Loops and Graphs: stop babysitting agents, approve only the last step

Loops and Graphs: stop babysitting agents, approve only the last step

Source x.com Glean’d 2026-11-10 06:00 Read 11 min
AI summary

Two layers, split cleanly: a loop lives inside a node (produce, check, correct until green), a graph lives between nodes (what work exists, what runs in parallel, where results return). The argument is that a loop without a check that can actually fail is just a scheduler, and that most teams build the work first and bolt a model-based review onto the end. The graph layer gets four node types — splitter, worker, code node, gate — plus two return edges: a short correction edge that fixes the current run, and a long learning edge that feeds an accepted result back into the splitter's brief as a constraint. Gates should open by blast radius, not model confidence, with irreversible work in a lane that never opens. Written for engineers still approving every step by hand.

Original · 11 min
x.com ↗
§ 1

Loops and Graphs: how to stop babysitting agents and only approve the last step (full course)

Loops and Graphs:如何不再盯着 agent,只审批最后一步(完整课程)

§ 2

You check every step your agents take. Not because you want to, but because nothing else does.

Getting out of that chair takes two things, and almost everyone builds only one of them.

A loop makes a unit of work correct without you. A graph decides which units exist at all.

Here is the split, the mechanics that are not obvious, and the point where you approve one thing instead of everything.

agent 的每一步你都要过一遍。不是你愿意,而是没别的东西替你看。

想从这把椅子上站起来,需要两样东西,而几乎所有人都只造了其中一样。

loop 让一个工作单元在你不在场时也能做对。graph 决定到底有哪些单元存在。

下面讲这两者怎么分工、那些不显然的机制,以及你最终只需要审批一件事、而不是所有事的那个点。

§ 3

Strip everything else away and a loop is four parts: produce, check, correct, repeat until green.

The check is the whole thing.

Without something that can fail the work while you are out of the room, you do not have a loop. You have a scheduler.

把别的东西都剥掉,一个 loop 就四部分:产出、检查、纠正,重复到全绿。

检查就是全部。

如果没有任何东西能在你离开房间时判定这份工作不合格,你手上就不是 loop,而是调度器。

§ 4

This sounds obvious and almost nobody writes the check first.

They build the work, then bolt a review onto the end, and the review is another model asked to look at the output.

Two optimists agreeing.

Write the condition first, and write it so a program could evaluate it:

GREEN    the test suite exits 0
GREEN    every claim carries a source line
GREEN    the diff touches only files listed in the plan

这话听着显然,可几乎没人先写检查。

大家先把活干出来,再在末尾焊上一个 review,而这个 review 就是再叫一个模型去看输出。

两个乐观主义者达成一致。

先把判定条件写出来,而且要写成程序能执行的形式:

GREEN    the test suite exits 0
GREEN    every claim carries a source line
GREEN    the diff touches only files listed in the plan
§ 5
NOT A CHECK   the output looks good
NOT A CHECK   the model says it is confident
NOT A CHECK   no errors were raised

That last one catches careful people. Absence of an error is not evidence of correctness.

Build a loop on it and you get a system that confidently repeats a mistake until the budget runs out, with a clean log the whole way.

NOT A CHECK   the output looks good
NOT A CHECK   the model says it is confident
NOT A CHECK   no errors were raised

最后那条最容易骗到认真的人。没有报错,不等于做对了。

在这种东西上搭 loop,你会得到一个自信地重复同一个错误、直到预算烧光的系统,而且全程日志干干净净。

§ 6

A loop makes one unit of work better. That is its entire job, and it is very good at it.

It cannot decide which units exist, or their order, or notice that two of the five steps never needed to wait for each other.

loop 让一个工作单元变得更好。这就是它的全部职责,而它做得很好。

它决定不了有哪些单元、它们的顺序,也发现不了五个步骤里有两个根本不必互相等待。

§ 7

So you get a very good agent running the wrong three steps, in the wrong order, one at a time.

Every step is correct. The result is still slow and still wrong-shaped, and tuning the loop will not fix it, because the fault is not inside any unit.

That is the moment people blame the model. It is also the moment the next layer starts paying for itself.

于是你得到一个非常优秀的 agent,按错误的顺序、一次一个地跑着错误的那三个步骤。

每一步都是对的。结果依然慢,形状依然是错的,而调 loop 修不好它,因为毛病不在任何一个单元内部。

人就是在这个时刻开始怪模型。也是在这个时刻,上面那一层开始回本。

§ 8

A graph is the shape of the work: what runs, what runs at the same time, what waits, what never runs at all, and where results go back.

Two things and nothing else. A node is a unit of work: one bounded job, one input in, one output out.

An edge is a dependency, this node's output feeds that node's input.

graph 是工作的形状:什么跑、什么同时跑、什么在等、什么根本不跑、结果回到哪里。

只有两样东西,别的没有。节点是一个工作单元:一件有边界的事,一个输入进,一个输出出。

边是依赖关系:这个节点的输出喂给那个节点的输入。

§ 9

The mistake behind every unnecessary wait is treating "and then" as an edge.

Summarize the file and then check the weather has no edge between them. The weather does not consume the summary.

Those are two independent nodes that a linear script chained, and the chaining came from the order you typed them.

So run this on every arrow in a pipeline you already have: does the next step actually read the previous step's output?

If you cannot name the variable that crosses, there is no edge, and the wait is pure waste.

Most chains have two or three arrows like that, and finding them is usually the largest single speedup available.

The full breakdown of all five layers, in the order they matter, is here: agent-layers.vercel.app

所有不必要的等待,背后都是同一个错误:把「然后」当成了一条边。

先把文件总结一下,然后查天气——这两件事之间没有边。天气不消费那份总结。

它们是两个独立节点,是线性脚本把它们串了起来,而串起来的理由只是你打字的顺序。

所以拿你现有的流水线,对每根箭头问一句:下一步真的读上一步的输出吗?

如果你说不出跨越箭头的是哪个变量,那就没有边,这段等待纯属浪费。

大多数链条里都有两三根这样的箭头,把它们找出来,通常就是能拿到的最大一次提速。

五层的完整拆解,按重要程度排序,在这里:agent-layers.vercel.app

§ 10

Splitter, worker, code node, gate. That is the whole vocabulary.

The splitter cuts the work into units and sits at the front.

It decides more than any other node, because splitting by the wrong dimension wastes everything downstream.

Cut a repository by folder and four workers audit the same three files.

Cut by blast radius and each one sees something the others cannot.

拆分器、worker、code node、闸门。整套词汇就这些。

拆分器把工作切成单元,站在最前面。

它的决定比任何其他节点都重要,因为按错误的维度切,下游全都在浪费。

按文件夹切一个代码仓库,四个 worker 会去审同样那三个文件。

按影响半径/blast radius 切,每个 worker 都能看到别人看不到的东西。

§ 11

Workers do one unit each, with one lens, in their own context. That last part gets skipped constantly.

Give four auditors a shared window and they converge: the first writes a finding, the rest read it, and all four reports centre on the same thing.

You paid four times for one opinion with three echoes.

worker 各做一块,各用一只镜头,各有自己的上下文。最后这一点被跳过的次数最多。

给四个审计员一个共享窗口,他们会趋同:第一个写下发现,其余人读到它,四份报告最后都围着同一件事转。

你付了四份钱,买到一个观点加三个回声。

§ 12

The code node is the one people forget exists. Merging, ranking, deduplicating, comparing every export before and after.

None of that is reasoning. Each has exactly one correct answer, each is a few lines of code, and running it through a model adds cost, latency and variance to a step that had none.

If you can describe the transformation without using the words judge, decide, assess or summarize, it is code.

A graph where every edge is an agent pays rent on its own wiring.

code node 是大家忘了还存在的那一类。合并、排序、去重、对比改动前后的每一份导出。

这些都不是推理。每一件都只有一个正确答案,每一件都只是几行代码;交给模型来做,只会给一个本来没有成本、没有延迟、没有波动的步骤,把这三样都加上。

如果你描述这个转换时用不到「判断」「决定」「评估」「总结」这几个词,那它就是代码。

一个每条边都是 agent 的 graph,是在为自己的接线付租金。

§ 13

One sentence resolves the whole confusion. The loop lives inside a node. The graph lives between them.

Inside one unit: produce, check, correct, repeat until green.

Between units: split, fan out, merge, gate, send back. None of the second list is expressible from inside a single unit.

So you do not choose. A graph without loops in its nodes produces unverified work in parallel, which is worse than serially because there is more of it.

A loop without a graph around it is one very good step in a queue nobody designed.

一句话理清全部混乱:loop 活在节点内部,graph 活在节点之间。

一个单元内部:产出、检查、纠正,重复到全绿。

单元之间:拆分、并发、合并、过闸、打回。后面这一串,在单个单元内部一件事也表达不了。

所以这不是二选一。节点里没有 loop 的 graph,会并行产出未经核验的工作,比串行更糟,因为量更大。

外面没有 graph 的 loop,只是没人设计过的队列里一个很好用的步骤。

§ 14

A graph without a way back is a pipeline. It produces output and forgets.

Next week it starts from the same place with the same blind spots.

Working graphs have two return paths, doing different jobs.

The correction edge is short. A gate rejects one unit back to the step that produced it, and it fixes the run you are in.

The learning edge is long. An accepted result goes back to the splitter as a constraint, and it fixes every run after.

Almost everyone builds the first and skips the second. The tell is a system that is fast and never gets smarter.

没有回路的 graph 就是一条流水线。它产出结果,然后忘掉。

下周它从同一个起点出发,带着同样的盲区。

能工作的 graph 有两条回边,各干各的活。

纠错边很短。闸门把一个单元打回产出它的那一步,修的是当前这一轮。

学习边长。被接受的结果回到拆分器,变成一条约束,修的是之后的每一轮。

几乎所有人都造了第一条,跳过了第二条。迹象很好认:系统很快,但从不变聪明。

§ 15

The learning edge does not carry the output, it carries a constraint derived from it:

ACCEPTED   utils slice ported, green on first pass
DERIVED    adapters preserve keyword args exactly
LANDS IN   the splitter's brief for every later slice

Notice where it lands. Not in the worker's instructions, in the brief that shapes how the work gets cut.

A confirmed cause becomes a rule, so the next break starts where this one ended.

学习边带回去的不是输出,而是从输出里提炼出的约束:

ACCEPTED   utils slice ported, green on first pass
DERIVED    adapters preserve keyword args exactly
LANDS IN   the splitter's brief for every later slice

注意它落在哪。不是落进 worker 的指令,而是落进决定「活怎么切」的那份 brief。

一个被确认的病因变成一条规则,于是下一次断裂从这一次结束的地方开始。

§ 16

This is the most expensive mistake on the return path, and it is worth stating plainly.

Four slices were ported. One fails its tests. If the whole batch goes back, three correct slices get rewritten.

Their next version is different, not better, because nothing was wrong with them.

Now you re-verify all four, and any of the three may fail this time for unrelated reasons.

You converted one failure into four uncertain outcomes and paid for the privilege. Do it twice in a run and it never converges.

From the outside this looks like the model failing repeatedly. It is a return path destroying correct work.

这是回退路径上最贵的错误,值得直说。

移植了四块切片,其中一块测试没过。如果整批退回,另外三块正确的切片也会被重写。

它们的新版本不一样了,但并没有更好,因为它们本来就没毛病。

然后你得重新验证四块,而这三块里任何一块这次都可能因为不相干的理由挂掉。

你把一次失败变成了四个不确定的结果,还为这个特权付了钱。一轮里来上两次,它永远收敛不了。

从外面看,这像是模型在反复失败。实际上是回退路径在毁掉正确的工作。

§ 17

Four things travel with a return, and each is doing a job:

UNIT      handlers slice
VERDICT   red
REASON    test_auth_redirect failed
EVIDENCE  expected 302, got 200, handlers/auth.py:88
SCOPE     fix this file only, do not touch other slices

The scope line matters more than it looks.

Without it a returned unit grows: the agent opens the file, notices two adjacent issues, fixes those too, and your one-slice correction becomes a four-file diff nobody reviewed.

Cap it at three attempts. If a unit fails three corrections the problem is in the plan that produced it, and the loop cannot see the plan.

一次回退要带四样东西,每样都各司其职:

UNIT      handlers slice
VERDICT   red
REASON    test_auth_redirect failed
EVIDENCE  expected 302, got 200, handlers/auth.py:88
SCOPE     fix this file only, do not touch other slices

SCOPE 这一行比看上去重要。

没有它,被退回的单元会长大:agent 打开文件,注意到旁边还有两个问题,顺手也改了,你的一次单切片修正就变成一个四文件、没人审过的 diff。

把它卡在三次尝试。一个单元如果三次纠正都过不了,问题出在产出它的计划里,而 loop 看不见计划。

§ 18

Most write-ups build a confidence score, set a threshold, and let anything above it through. That is the wrong variable.

Confidence is the weakest input in that decision, for a reason that is easy to miss: it is the only one the model can influence.

The strong variable is what happens if the change is wrong. Sort work by how expensive the mistake is to undo:

大多数文章会造一个信心分,设一个阈值,高于阈值的就放行。这是选错了变量。

信心是那个决定里最弱的输入,原因很容易被忽略:它是模型唯一能施加影响的输入。

真正强的变量是:如果这次改动是错的,会发生什么。按「一次错误有多贵才能撤掉」给工作排序:

§ 19

Reversible and contained. A copy change, a test, an isolated function with coverage. One bad merge costs a revert, so this lane can open first.

Reversible but wide. A shared utility, a schema addition, anything a dozen callers touch. Gate on deterministic checks plus a clean trajectory.

Hard to reverse. Migrations, deletions, anything writing to production data or moving money. This lane does not open, regardless of score.

可逆且封闭。改个文案、加个测试、一个被覆盖到的孤立函数。一次错误合并的代价就是回滚一次,所以这条道可以最先打开。

可逆但面广。共享工具函数、加一个 schema 字段、任何有十几个调用方会碰的东西。用确定性检查加干净的轨迹来把闸。

难以撤销。数据迁移、删除、任何写生产数据或动钱的操作。这条道不开,分数再高也不开。

§ 20

That third row is not a threshold set very high. It is a lane that does not open, and the distinction matters because thresholds get adjusted and closed lanes do not.

Inside an open lane the gate reads evidence in order: deterministic results, then the trajectory of this run, then how often work from this node has been rolled back before, and the model's own assessment last.

第三行不是「阈值设得很高」,而是一条不开的道。这个区别很重要,因为阈值会被往下调,而关闭的道不会。

在开着的道里,闸门按顺序读证据:先是确定性结果,然后是本轮的轨迹,再是这个节点的工作以前被回滚过几次,模型自己的评估放最后。

§ 21

Take one thing you do repeatedly. Draw the splitter, the lanes, the merge, one gate, one back edge.

Build the gate first. Everything gets easier once something can fail loudly, and a graph without a gate is just a faster way to produce unverified output.

Then the lanes. Then the learning edge, last, because you cannot derive constraints from accepted results until something is accepting results.

挑一件你反复在做的事。把拆分器、车道、合并、一道闸、一条回边画出来。

先造闸门。一旦有东西能大声地失败,其他一切都变简单;而没有闸门的 graph,只是更快地产出未核验结果的方式。

然后造车道。最后才是学习边,因为你得先有东西在接受结果,才能从被接受的结果里提炼约束。

§ 22

Put the human on one step, at the point of highest consequence and lowest reversibility.

Approve the merge. Choose which fixes ship. Not reviewing intermediate output, not confirming each step.

A human in the middle of a graph becomes the slowest node in it, and the graph runs exactly as fast as a person reading things.

I put all five layers into a full course, twenty lessons with the templates, the configs and the order to build them in: agent-layers.vercel.app

把人放在一步上,放在后果最大、最难回滚的那个位置。

审批合并。决定哪些修复上线。不是去审中间输出,也不是逐步确认。

站在 graph 中间的人,会变成 graph 里最慢的那个节点,而 graph 的运行速度,正好等于一个人读东西的速度。

我把五层做成了一门完整课程,二十节课,含模板、配置,以及按什么顺序搭:agent-layers.vercel.app

§ 23

Three lines hold the whole discipline. Measure the path, not only the answer it landed on.

A verdict that does not change what runs next is a report.

And any failure you do not turn into a permanent constraint, you will meet again.

三句话概括整套纪律。测路径,不要只测它最后落在的那个答案。

一个不改变下一步跑什么的裁决,只是一份报告。

任何你没变成永久约束的失败,你都会再遇到一次。

§ 24

Most people will keep tuning one loop and calling it a system.

The ones who draw the graph around it will run a fleet, and never quite understand why everyone else finds it so hard to keep up.

大多数人会继续调那一个 loop,然后管它叫系统。

把 graph 画在它外面的人,会跑起一支编队,并且始终不太明白为什么别人觉得跟上这么难。

§ 25

If you want the one-page version of the graph layer before anything else, DM me the word Graph.

Also follow me for more on agent internals, and subscribe to my Telegram channel:

https://t.me/+75nMf005jRpjMDU1

如果你想先拿到 graph 层的一页纸版本,私信我发 Graph 这个词。

也欢迎关注我,看更多 agent 内部机制的内容,并订阅我的 Telegram 频道:

https://t.me/+75nMf005jRpjMDU1

Open source ↗