删掉不存在的箭头:从 1 条 prompt 到 100 个 agent 的图工程八步
这篇文章主张把 agent 工作流本身当作一个工程对象:在 prompt/context/harness/loop 之外,增加“图工程”层。作者的核心观察是,默认线性编排把“顺序”误当成“依赖”,大量箭头并不读上游输出,删除这些假依赖后才能真正并行;所谓 100 个 agent,不是 100 个角色,而是同一角色带各自的上下文窗口实例化 100 次。全篇给出八步方法,覆盖节点契约、四种拓扑、join 时机、分类器与路由表分离、验证节点、持久化状态,并给出“什么时候不该用图”的判断清单。作者坦诚并行广度是有代价的,引用了 Anthropic 多智能体研究的 token 消耗数据。适合正在把单 agent 原型演进为多 agent 生产系统的工程师;没有运行代码,结尾有课程引流。
Graph Engineering: from 1 prompt to 100 agents running in one system (full 8-step course)
By @hanakoxbt · 2026-08-11T13:23:05.000Z

A research task comes in at nine in the morning.
Your agent reads the brief, searches, reads what it found, searches again, drafts, checks itself, and hands you something at half past ten.
Ninety minutes for work where almost nothing depended on anything else.
Six of those searches never needed each other. Four of them could have run while the fifth was still loading.
Nothing was slow. Everything was queued.
That is not a prompting problem and it is not a model problem.
It is the shape of the work, and the shape is the thing nobody designs.
图工程:从一个提示词到同一系统中跑 100 个智能体(完整 8 步课程)
@hanakoxbt · 2026-08-11T13:23:05.000Z

上午九点,一个研究任务进来了。
你的智能体读取简报、搜索、阅读搜到的内容、再搜索、起草、自我检查,然后在十点半把结果交给你。
这九十分钟的工作里,几乎没有哪一步依赖另一步。
其中六次搜索彼此不需要等待;四次搜索本可以在第五次还在加载时并行跑。
没有哪个环节慢,全都在排队。
这不是提示工程的问题,也不是模型的问题。
这是工作的形态,而形态恰恰是没人设计的东西。
Step 1 - most of your edges are not real
The default agent workflow is a line, because that is how instructions get written. Do this, then that, then the other thing.
But sequence is not dependency.
An edge between two steps should mean one thing only: the second step reads what the first step produced.
If it does not read it, the edge is imaginary, and you are paying for it in wall clock time.
Take the research example. Company filings, academic papers, competitor pricing, expert commentary. None of these four consume each other. They all feed the same synthesis at the end.
Written as a chain, that is four round trips in a row.
Written as a fan, it is one round trip and a join.
This is where the hundred comes from, by the way. Not from cleverness. From noticing that most of the arrows in your diagram were never dependencies, and deleting them.

Ask one question of every arrow in your system:
- does the next step actually read the previous output
- or does it just happen to be written underneath it Cut every arrow that fails that test.
Most people find they have three real dependencies inside a chain of twelve.
第 1 步:大多数连线并不是真实的
默认的智能体工作流是一条直线,因为指令就是这么被写出来的。先做这个,再做那个,再做另外一件事。
但顺序不是依赖。
两个步骤之间的连线只应表达一件事:第二步读取了第一步产生的输出。
如果它不读取,这条线就是想象出来的,而你在为它付出实际运行时间。
拿研究这个例子来说。公司文件、学术论文、竞品定价、专家评论。这四个来源互相并不消费彼此的输出,它们最终都汇入同一个综合环节。
写成链条,就是连续四次往返。
写成扇状,就是一次往返加一次汇合。
顺便说一句,一百这个数字就是这么来的。不是靠聪明,而是靠发现图中大多数箭头从来都不是依赖,然后删掉它们。

对你系统中的每一条箭头都问一个问题:
- 下一步真的读了上一步的输出吗?
- 还是它只是恰好被写在下面? 删掉所有通不过这个测试的箭头。
大多数人会发现,一条十二步的链条里只有三个真正的依赖。
Step 2 - a node you cannot describe is a node you cannot route
Once work is parallel, something has to decide where each result goes. That decision needs to read the result, which means the result has to have a shape.
A node that returns prose forces the next node to interpret it. Interpretation is another model call, another sample, another chance to be wrong about something that was already known.
Every node in a working graph has four properties.
One job, small enough to name in three words.
An explicit input, so you know what it needs.
A structured output, so the graph can branch on it without asking a model what it means.
A named failure state, so a failure is a value and not an exception.
That last one matters more than it sounds. When a node can return not_found as data, the graph routes it. When it throws, the graph stops.
Contracts also make nodes swappable. Change the model, change the prompt, change the tool, and as long as the shape of the output holds, nothing downstream needs to know.
第 2 步:无法描述的节点就无法路由
一旦工作并行化,就必须有什么东西来决定每个结果去哪里。这个决定需要读取结果,也就是说结果必须有一种形状。
返回非结构化文本的节点会逼着下一个节点去解读它。解读就是又一次模型调用、又一次采样、又一次对已知信息出错的机会。
一个能工作的图中的每个节点都有四个属性。
一项职责,小到能用三个词命名。
一个明确的输入,让你知道它需要什么。
一个结构化输出,让图可以不问模型就基于它做分支。
一个命名的失败状态,让失败成为值,而不是异常。
最后这一点比听上去更重要。当节点可以把 not_found 当作数据返回时,图可以对它做路由;当节点直接抛出异常时,整个图就停了。
契约也让节点可以替换。换模型、换提示词、换工具,只要输出形状不变,下游什么都不用知道。
Step 3 - four shapes cover almost everything
You do not need a pattern library. Production graphs are combinations of four things.
The chain, where each step genuinely needs the last. Rare, and usually shorter than people think.
The fan, where one job splits into independent branches that run together and merge at the end. This is the workhorse: research, review, audit, comparison, anything with breadth.
The router, where the system inspects the request and picks a path. Small work takes the short one. Risky work earns the long one.
The controlled cycle, where a node repeats until evidence says it is done. Not until it feels done.
第 3 步:四种形状覆盖几乎所有场景
你不需要一套模式库。生产级图就是四种东西的组合。
链:每一步确实需要上一步。这种很少,而且通常比人们以为的短。
扇:一个任务拆成相互独立的分支,并行跑完后在末端汇合。这是主力:研究、评审、审计、对比,任何有广度的工作。
路由器:系统检查请求后选择一条路径。小任务走短路径,高风险任务走长路径。
受控循环:节点一直重复,直到证据说完成,而不是直到它“感觉”完成。
The fan is the one that produces the number in the title. A hundred agents is not a hundred different roles. It is one role, instantiated a hundred times, each with its own slice of the problem and its own context window, all reporting to the same join.

扇就是产生标题里那个数字的形状。一百个智能体不是一百种不同角色,而是同一个角色被实例化一百次,每次拥有问题的一个切片和自己的上下文窗口,最终都报告给同一个汇合点。

Step 4 - a join is a decision, not a formality
Parallelism is easy to add and easy to abuse. The mistake is putting a barrier after every stage, which quietly turns your fan back into a chain.
A join is worth waiting for only when the next node needs the complete set.
It is needed when you are deduplicating across sources, ranking all candidates against each other, comparing alternatives, or deciding whether coverage is sufficient.
It is not needed when each result can move on by itself. In that case, keep it streaming.
And when you do join, one failed branch should not take the other ninety-nine with it. Collect what settled, note what did not, and let the graph decide whether that is enough to continue.
The topology, not the number of agents, is what decides where your system waits.
第 4 步:汇合是一个决策,不是走过场
并行很容易加,也很容易被滥用。常见的错误是在每个阶段后面都放一道屏障,这会悄悄把扇变回链。
只有当下一步需要完整集合时,汇合才值得等待。
当你需要跨来源去重、让所有候选相互排序、比较备选方案,或者判断覆盖是否充分时,需要汇合。
当每个结果可以各自继续前进时,就不需要汇合。这种情况下,保持流式。
而当你确实要汇合时,一个失败的分支不应该拖垮另外九十九个。收下已经落定的,记下还没落定的,让图决定这些是否足以继续。
决定系统在哪里等待的是拓扑,而不是智能体数量。
Step 5 - let the model judge, let the graph decide
Routing is where people give away more control than they meant to.
A model classifying a request is fine. It is good at that. A model choosing what the system is allowed to do next is a different thing entirely.
Split it.
The classifier is probabilistic and returns a label. The route table is deterministic and maps labels to paths. Low risk goes to the quick path. High risk goes to the full audit. Anything unrecognised goes to a human.
You get the model's flexibility on the judgement and none of its improvisation on the authority.
This also makes the system explainable. When something went the wrong way, you can point at a label and a table instead of guessing at a paragraph of reasoning that no longer exists.
第 5 步:让模型判断,让图决策
路由是人们交出比预想更多控制权的地方。
模型对请求做分类没有问题,这是它擅长的。但让模型选择系统接下来被允许做什么,就完全是另一回事了。
把两者拆开。
分类器是概率性的,返回一个标签。路由表是确定性的,把标签映射到路径。低风险走快速路径,高风险走完整审计,无法识别的交给人类。
你得到的是模型在判断上的灵活性,而不是它在决策权上的即兴发挥。
这也会让系统可解释。当某件事走错了方向,你可以指着一个标签和一张表,而不是去猜一段已经不存在了的推理文字。
Step 6 - the most valuable node produces nothing
In every graph that survives contact with production, the highest-leverage node is a verifier. It adds no content. Its entire job is to stop weak work from moving downstream.
A verifier can check whether every claim carries a source, whether the source actually supports the claim, whether the output matches the schema, whether the tests pass, whether a second independent path reached the same conclusion.
Put it on the edge, between the generator and everything after it.
And do not ask one agent to produce, approve, and publish in the same context. It will approve. The review is drawn from the same distribution that produced the work, which is why a self-check catches formatting and misses being wrong.
Separate the roles. Separate the prompts. Separate the failure boundaries.
This is the same gate logic as merging code: something outside the worker decides whether the work is allowed to continue.

第 6 步:最有价值的节点什么都不产出
在每个经得住生产环境考验的图里,杠杆率最高的节点是验证器。它不增加任何内容,全部工作就是阻止薄弱的下游环节继续前进。
验证器可以检查每条主张是否带来源、来源是否真的支撑主张、输出是否符合 schema、测试是否通过、另一条独立路径是否得到相同结论。
把它放在生成器与后续一切之间的连线上。
不要要求同一个智能体在同一个上下文里既生产、又审批、又发布。它会批准。审查和产出来自同一个分布,这正是自查能抓住格式问题、却漏掉“根本就是错的”的原因。
把角色分开,把提示词分开,把失败边界分开。
这和合并代码的闸门逻辑一样:由执行者之外的东西决定工作是否被允许继续。

Step 7 - state is the part the diagram hides
Boxes and arrows look clean until the run dies halfway through and you find out the system has no idea what already happened.
A graph that runs in production keeps durable state: which node is current, which have completed, what artifacts exist, what decisions were made and on what evidence, what budget is left, how many retries have been spent, which human approvals are recorded.
Two rules make this survivable.
Do not pass transcripts between nodes. Pass references. A research node stores its report and returns an identifier. The reviewer reads the artifact directly instead of receiving a summary that has been through three retellings.
Make writes idempotent, so a retry does not create a second copy of something that already exists.
At any moment the graph should be able to answer three questions: what has already happened, why was this route taken, and where can execution safely resume.
If it cannot answer all three, it is a demo with good diagrams.
第 7 步:状态是图里藏起来的部分
盒子和箭头看起来干干净净,直到运行到一半崩溃,你才发现系统根本不知道已经发生了什么。
一个在生产环境运行的图会保存持久状态:当前是哪个节点,哪些已完成,存在哪些产物,做过哪些决策以及依据什么证据,还剩多少预算,已经用了多少次重试,记录了哪些人工审批。
两条规则让它能扛住崩溃。
不要在节点之间传递完整对话记录,传递引用。研究节点把报告存好,返回一个标识符。评审者直接读取产物,而不是接收一份已经转述了三遍的摘要。
让写入具备幂等性,这样重试不会给已经存在的东西再创建一份副本。
在任何时刻,图都应该能回答三个问题:已经发生了什么、为什么走这条路、执行可以从哪里安全恢复。
如果三个问题都答不上来,那就只是带漂亮图表的演示品。
Step 8 - the shape is your cost model
A graph is not automatically cheaper. It is usually more expensive, and the honest version of this course says so.
Anthropic reported that their multi-agent research system outperformed a single agent by a wide margin on breadth-first work, and that it consumed roughly fifteen times the tokens of a normal chat interaction.
That is the trade. Parallel breadth costs money.
So the shape has to earn it.
- cheap models for bounded extraction, classification, and formatting
- strong models for decomposition, synthesis, and hard verification
- short paths for simple requests
- the full graph only for work whose value justifies the coordination
A hundred agents is the right answer when the task is genuinely wide, when the branches are independent, and when the result is worth the spend.
It is the wrong answer when one context could have held the whole problem.

第 8 步:形状就是你的成本模型
图并不会自动更便宜。它通常更贵,这门课的诚实版本会把这一点说出来。
Anthropic 报告说,它们的多智能体研究系统在广度优先的工作上大幅胜过单个智能体,但消耗的 token 大约是普通聊天交互的十五倍。
这就是代价:并行广度要花钱。
所以形状必须把这份钱挣回来。
- 有边界的提取、分类和格式化用便宜模型
- 分解、综合和高难度验证用强模型
- 简单请求走短路径
- 只有价值配得上协调成本的工作才走完整图
一百个智能体是正确的答案,当任务确实很宽、各分支相互独立、结果也值得这笔开销时。
当一个上下文本来就能装下整个问题时,它就是错误的答案。

When a graph is the wrong tool
Keep one agent in one loop when the task is short, when a single context holds everything relevant, when there are no independent branches, when failure is cheap, and when a person can check the result in a minute.
Reach for a graph when work can genuinely run in parallel, when different nodes need different tools or permissions, when outputs need independent verification, when the run has to survive an interruption, or when cost and authority need to be controlled by route.
Start with the loop. Draw the graph when the dependencies force you to, not before.
什么时候图是错的工具
任务很短、单个上下文装得下所有相关内容、没有独立分支、失败成本很低、人一分钟就能检查结果时,保留一个智能体在一个循环里就好。
当工作真的可以并行、不同节点需要不同工具或权限、输出需要独立验证、运行必须能扛住中断,或者成本和决策权需要按路由来控制时,再引入图。
从循环开始。当依赖逼你必须画图时再画,不要提前画。
The layers, in order
Prompt engineering improves the message.
Context engineering controls what the model sees.
Harness engineering builds the machinery around the call.
Loop engineering makes one unit of work improve through feedback.
Graph engineering coordinates the whole job.
The model is one node in that picture. Everything that makes it reliable, fast, and affordable is the system you built around it.
Going from one prompt to a hundred agents is not a matter of spawning more.
It is a matter of knowing which arrows were never real.
各层,按顺序
提示工程改进的是发给模型的那条消息。
上下文工程控制模型看到什么。
Harness 工程围绕调用搭建机器。
循环工程让一个工作单元通过反馈改进。
图工程协调整个任务。
模型只是那幅图里的一个节点。让它可靠、快速、便宜的一切,都是你围绕它构建的系统。
从一个提示词到一百个智能体,不是靠生成更多实例。
而是靠知道哪些箭头从来都不是真的。
I put the full agent engineering course together separately, covering all five layers with the templates and the rollout order.
DM me the word "Agent" to get it.
Also follow me for more on agent internals, and subscribe to my Telegram channel:
我把完整的智能体工程课程单独整理了出来,覆盖全部五层,包括模板和上线顺序。
私信我“Agent”这个词就可以拿到。
也欢迎关注我获取更多智能体内部机制的内容,并订阅我的 Telegram 频道: