Sub-agent 和 multi-agent:
什么时候拆,context 怎么传?

英文问法When would you split a task across sub-agents instead of using one agent? · A sub-agent starts with an empty context. What goes into its brief? · Do more agents make the system faster or slower?

考过别家面经原题:阿里边缘 BU 一面(校招,发帖 2026-09-03)「如何保证传给子 Agent 的上下文足够完整,不会遗漏关键信息?」「引入多层 Agent 和多个子 Agent 后,执行效率是否会变慢?」(牛客)、蔚来软件开发二面(发帖 2026-09-17)「子Agent返回结果全部正确,但主Agent汇总时出现幻觉,原因是什么,有什么优化方案」(牛客) · Unity 自己的材料:FlashVector 每个 serving layer 有自己的 layer agent,§6 提到 "parallel agent workflows",没写并行多少个、怎么协调 · 中文面经样本里有 15 帖问 sub-agent 和 multi-agent · 没有 Unity 自己的面经原题

先弄清楚:每个概念是什么

Sub-agent
主 agent 派出去的另一个 agent,context 从空白开始。像把事情交给没开过会的同事,他只知道你写给他的那张纸,这张纸就是 brief。
Planner 和 worker
planner 拆任务和分任务,worker 是干活的 sub-agent。
确定性代码
不调 LLM 的普通程序逻辑。计数、停止条件、哪个结果留下,都写在这里。

看图:planner 分任务,确定性代码收结果

planner 拆任务,写 brief brief worker 1 空 context + brief worker 2 空 context + brief worker 3 空 context + brief 结论 + 证据 确定性代码:收结果,定去留
图 1:worker 各自从空 context 加一份 brief 开始,只交结论和证据,由确定性代码决定哪个留下。

30 秒回答

I split in three cases: the subtasks are independent, one context can't hold all the tool output, or the judge must be separate from the author. A sub-agent starts with an empty context, so the brief has to carry the goal, the constraints, what's been tried and the output format. It returns a summary with evidence, not its whole transcript, and deterministic code decides what to keep. The cost is more total tokens and coordination overhead, and tasks with serial dependencies get slower when split, so I don't split those.

什么时候拆,代价是什么

情况拆不拆原因
子任务互相独立,比如并行试几种 kernel 写法拆并行能省 wall time
一个 context 装不下全部 tool 输出拆worker 自己消化原始输出,只交回结论
评审要和作者分开拆同一个 agent 既写码又评判,是一篇 workshop 论文归纳的五类失败之一
步骤之间有串行依赖不拆每次交接多一份 brief 和一次摘要,更慢,还会丢信息

总 token 更多,是因为每个 worker 都要重新读一遍背景。下面的数字是举例。4 个独立子任务各要 10 分钟,串行是 40 分钟,并行约 10 分钟再加写 brief 和汇总的时间。单个 agent 做完要 60K token,4 个 worker 各用 30K 就是 120K,时间省了,token 翻倍。

Brief 写什么。目标、约束、已经试过的、输出格式,用固定模板逐项填。大段材料给文件路径,让 sub-agent 自己读,不靠主 agent 转述。

同类系统怎么编排

系统做法
KernelFalcon控制流写在确定性的 Python 里;默认 4 个并行 worker,各自保留 error context,第一个通过的胜出
Cursor × NVIDIAplanner 给 worker 分配并重新平衡任务;协调协议是一个 markdown 文件
KernelArc按策略分工的并行 agent,每个只改自己的 solution 目录;计数、停止条件、重启都在确定性代码里
KDAClaude Code 实现,Codex 每轮 review
FlashVector单链循环,每轮随机抽一层,只做一个改动;并行度论文没写

必答点

追问

sub-agent 的结果都对,主 agent 汇总时出了幻觉,怎么办?(蔚来原题)

让 sub-agent 按固定格式返回结论和证据,由确定性代码合并,主 agent 不凭印象重写。

两个 worker 要改同一个文件怎么办?

每个 worker 用自己的 workspace,别人的成果只读。合并时的覆写问题见 edit tool 的 hash 检查。

来源面经原帖:阿里边缘 BU 一面、蔚来二面 · KernelFalcon · Cursor × NVIDIA · KernelArc · FlashVector Algorithm 1、§6 · KDA · GeCoIn 2026 workshop 论文(五类失败) · ml-八股 08 第 38 题 · 同类系统对照表