2.3
Use subagents sparingly慎用子 agent慎用子 agent
This chapter assumes you have used an AI coding agent, such as Copilot in agent mode. Nothing else.
讀這一章,只需要用過一個寫程式的 AI agent,例如 Copilot 的 agent 模式。其他都不用。
读这一章,只需要用过一个写代码的 AI agent,比如 Copilot 的 agent 模式。别的都不需要。
The Knowledge經驗分享经验分享
In one sentence
Dividing the work has no value in itself. Another agent is worth it only when it buys one of four things: an independent check, parallel work, work that runs unattended, or a hard limit on tools.
一句話
分工本身沒有價值。多一個 agent,只有在它買到下面四樣之一時才值得:獨立檢查、並行工作、無人值守,或對工具的硬性限制。
一句话
分工本身不值钱。多加一个 agent,只有在它换来下面四样之一时才划算:独立检查、并行干活、无人值守,或者对工具的硬性限制。
For leaders
- The decision: approve an extra agent only when it buys one of the four: an independent check, parallel work, work that runs unattended, or a hard limit on tools.
- The risk: a team of role agents can cost several times the usage and time for the same result. In my test it was about 4.5 times the usage and 6 times the time, on four tasks run once each.
- The cost of doing it right: usually one extra agent, a reviewer, per task.
- Ask the team: "Which of the four does this agent buy, and did you try the task without it?"
給主管
- 要做的決定:多開一個 agent,只在它買到四樣之一時才批:獨立檢查、並行、無人值守、工具的硬限制。
- 風險:按職位分工的一組 agent,可能花幾倍的用量和時間,結果卻一樣。在我的測試裡,用量約 4.5 倍、時間約 6 倍;四個任務,各跑一次。
- 做對的成本:通常是每個任務多一個 agent,也就是檢查者。
- 可以問團隊:「這個 agent 買到的是四樣裡的哪一樣?不用它做過同一個任務嗎?」
写给管理者
- 要拍板的事:多加一个 agent,只在它换来四样之一时才批:独立检查、并行、无人值守、工具的硬性限制。
- 风险:按岗位分工的一组 agent,可能多花好几倍的用量和时间,结果却没差别。在我的测试里,用量约 4.5 倍,时间约 6 倍;一共四个任务,每个只跑了一次。
- 做对的代价:一般是每个任务多一个 agent,也就是负责检查的那个。
- 可以问团队:“这个 agent 换来的是四样里的哪一样?同一个任务,不用它试过吗?”
The problem
I once gave one AI three job titles. On the same four tasks it cost about 4.5 times as much, took about 6 times as long, and got nothing more right. Now one agent does the work, and a second one only checks.
First, three words this chapter uses all the time.
- An agent is an AI model that runs in a loop: it reads files, runs commands, changes code, and decides the next step by itself.
- Its context is everything it has seen in one conversation: your request, the files it read, what it tried. It is the agent's working memory, and it has a size limit.
- A subagent is a second agent that the first one starts for a piece of the work. It begins with an empty context.
The idea that feels right
Give the AI job titles: a planner, a developer, a reviewer, each its own agent. Teams of people work that way, and many tools make it a few clicks.
I built exactly that in an early version of my own Copilot setup. A coordinator read the request and wrote a plan. A builder made the changes. A reviewer checked them. Then I measured it against one agent working alone.
How I tested it
- The repository: a made-up data engineering project, 93 files in 5 areas. Made up, so the tasks and the right answers were known in advance.
- Four tasks, small to medium: add a pipeline; add a field across several areas; rename a pipeline and delete its old files; fix a formula, where the request also asked to change a file that must not be touched.
- Two ways: each task was done once by the three-role team, which also had a knowledge base to read (notes about the repository, written for agents). And once by a single agent on a top model, with no extra setup and the rules written into the request.
- Scoring: the same script checked every result by reading the files. Nobody judged by eye.
- What I counted: did it pass on the first try, how much usage it took (AI credits, what the platform charges you), and how long.
Both ways got all four right. So the team bought nothing in correctness, and paid about 4.5 times the usage and about 6 times the time.
Before you quote these numbers: four tasks, each run once, and the two sides were not set up the same way. Trust the direction (the team cost several times more for the same result), not the exact ratio. Costs and traps says more.
Where the extra cost went
I read the records of each run. The biggest waste was the handover. The coordinator studied the task carefully: it read the request and the files, and understood what had to change. Then it wrote a short plan and handed it over. The builder started with an empty context, read the plan, and had to study the same files again. The same understanding was paid for twice.
- The coordinator reads the request and the files. Now it understands the task.
- To hand over, it squeezes that understanding into a short plan.
- The builder starts with an empty context. All it has is the plan.
- To change the code, the builder has to read the same files again.
Why job titles do not help an AI
- People split roles because of human limits. No one learns every specialty, a day has 8 hours, and one person cannot be in two places at once. A model does not have these limits. Its real limit is the size of its context, and the four cases in the next section are all about that.
- A title carries no knowledge; a fitted setup does. "You are a designer" changes the tone, not what the agent knows. Two things do help: the know-how of the field written in files that any agent can read, and a set of tools fitted to the job. The first needs no second agent. The second can be a reason for one (case 4 below).
- Handoffs lose understanding. That is the picture above. Understanding has to be squeezed into a summary to be handed over, and the next agent needs more than the summary to act.
- What a fixed rule can decide, do not leave to a model. "Who works next" and "is it finished" often have fixed answers. A small program answers them right every time; a model answers them right most of the time.
- Rework starts from zero. In my setup, every round of checks starts a new reviewer, which reads the work again from the start.
問題
我曾經給一個 AI 安排了三個職位。同樣四個任務,用量約是 4.5 倍,時間約是 6 倍,答對的一個也沒多。現在一個 agent 做事,另一個只負責檢查。
先說這一章一直會用到的三個詞。
- agent:一個在迴圈裡工作的 AI 模型。它讀檔案、執行指令、改程式碼,自己決定下一步。
- 上下文:它在一次對話裡看過的全部東西:你的需求、它讀過的檔案、它試過的做法。這是 agent 的工作記憶,大小有上限。
- 子 agent:第一個 agent 為了一部分工作而開的第二個 agent。它從空的上下文開始。
感覺很對的做法
給 AI 安排職位:計劃的、開發的、檢查的,各是一個 agent。人的團隊就是這樣分工的,很多工具點幾下就能搭好。
我在自己早期的 Copilot 設定裡就是這樣搭的。協調者讀需求、寫計劃,實作者改程式碼,reviewer 做檢查。然後我拿它和一個 agent 單獨做事來比。
我怎麼測的
- 倉庫:一個虛構的資料工程專案,5 個領域、93 個檔案。用虛構的,是為了事先就知道任務和正確答案。
- 四個任務,從小到中等:加一條 pipeline;跨幾個領域加一個欄位;改一條 pipeline 的名字並刪掉舊檔案;修一個公式,而需求同時要求改一個不准動的檔案。
- 兩種做法:每個任務由三角色團隊做一次,團隊還有一份知識庫可讀(為 agent 寫的倉庫說明);再由一個用頂級模型的 agent 做一次,沒有額外設定,規則寫在需求裡。
- 打分:同一個腳本讀檔案來檢查每個結果,沒有人憑眼睛判斷。
- 數什麼:第一次就通過了沒有、用了多少用量(AI credits,也就是平台向你收的錢)、花了多久。
兩種做法四個都答對了。所以團隊在正確性上什麼也沒多買到,卻付了約 4.5 倍的用量、約 6 倍的時間。
引用這兩個數字之前要知道:只有四個任務,每個只跑一次,而且兩邊的設定不一樣。可以相信方向(同樣的結果,團隊貴了好幾倍),不要相信確切的倍數。代價和陷阱有更多說明。
多出來的錢花在哪
我讀了每一次執行的紀錄。最大的浪費在交接。協調者很認真地研究了任務:讀了需求和檔案,搞懂了要改什麼。然後它寫了一份簡短的計劃交出去。實作者從空的上下文開始,讀了計劃,只好把同樣的檔案再研究一遍。同一份理解付了兩次錢。
- 協調者讀了需求和檔案,看懂了這個任務。
- 為了交接,它把理解壓成一份簡短的計劃。
- 實作者從空的上下文開始,手上只有這份計劃。
- 要動手改程式碼,實作者只好把同樣的檔案再讀一遍。
為什麼職位對 AI 沒用
- 人分工是因為人的限制。沒有人學得會所有專業,一天只有 8 小時,一個人也不能同時在兩個地方。模型沒有這些限制。它真正的限制是上下文的大小,下一節的四種情況都和這有關。
- 職位不帶知識,合適的配置才有用。「你是設計師」只改變語氣,不改變 agent 知道什麼。真正有用的是兩樣:寫在檔案裡、任何 agent 都能讀的領域知識,以及一組適合這份工作的工具。前者不需要第二個 agent,後者可以是多開一個的理由(下面第 4 種情況)。
- 交接會丟掉理解。就是上面那張圖。理解要壓成摘要才能交出去,而下一個 agent 要動手,光有摘要不夠。
- 固定規則能決定的,別交給模型。「誰做下一步」「做完了沒」常常有固定的答案。一個小程式每次都答對,模型大多數時候答對。
- 返工從零開始。在我的設定裡,每一輪檢查都開一個新的 reviewer,從頭再讀一遍。
问题
我曾经给 AI 安排了三个岗位。同样四个任务,用量约是原来的 4.5 倍,时间约是 6 倍,做对的一个也没多。现在我的做法是:一个 agent 干活,另一个只负责检查。
先交代这一章反复会用到的三个词。
- agent:在一个循环里干活的 AI 模型。它读文件、跑命令、改代码,自己决定下一步做什么。
- 上下文:它在一次对话里看过的所有东西:你的需求、它读过的文件、它试过的办法。这是 agent 的工作记忆,容量有上限。
- 子 agent:第一个 agent 为了某一部分工作而开的第二个 agent。它从空白的上下文开始。
看起来很对的做法
给 AI 分岗位:做计划的、写代码的、做检查的,各一个 agent。人的团队就是这么分工的,很多工具点几下就能搭起来。
我早期的 Copilot 配置就是这么搭的。协调者读需求、写计划,开发者改代码,reviewer 做检查。然后我拿它和一个 agent 单干做了对比。
我是怎么测的
- 仓库:一个虚构的数据工程项目,5 个领域,93 个文件。用虚构的,是为了事先就知道有哪些任务、正确答案是什么。
- 四个任务,从小到中等:加一条 pipeline;跨几个领域加一个字段;给一条 pipeline 改名并删掉旧文件;修一个公式,而需求同时要求改一个不许动的文件。
- 两种做法:每个任务让三角色团队做一次,团队还有一份知识库可以读(写给 agent 看的仓库说明);再让一个用顶级模型的 agent 做一次,不加额外配置,规则写在需求里。
- 怎么打分:同一个脚本读文件,检查每个结果,不靠人眼判断。
- 统计什么:是不是一次就通过、用了多少用量(AI credits,也就是平台向你收的钱)、花了多长时间。
两种做法四个任务全做对了。也就是说,团队在正确性上什么也没多换来,却多付了约 4.5 倍的用量、约 6 倍的时间。
引用这两个数字之前要知道:只有四个任务,每个只跑一次,而且两边的配置不一样。方向可以信(结果一样,团队贵好几倍),具体倍数别当真。代价和坑里有更多说明。
多花的钱去哪了
我把每次运行的记录都看了一遍。最大的浪费在交接上。协调者把任务研究得很透:读了需求和文件,弄清楚了要改什么。然后它写了一份简短的计划交出去。开发者从空白的上下文开始,读完计划,只好把同样的文件再研究一遍。同一份理解,付了两次钱。
- 协调者读了需求和文件,弄懂了这个任务。
- 为了交接,它把理解压缩成一份简短的计划。
- 开发者从空白的上下文开始,手里只有这份计划。
- 要动手改代码,开发者只好把同样的文件再读一遍。
岗位为什么对 AI 没用
- 人要分工,是因为人有局限。没人能精通所有专业,一天只有 8 小时,一个人也不能同时在两个地方。模型没有这些局限。它真正的局限是上下文的容量,下一节的四种情况都和这一点有关。
- 岗位本身不带知识,合适的配置才有用。“你是设计师”只会改变语气,不会改变 agent 知道什么。真正管用的是两样:写在文件里、任何 agent 都能读的领域知识,以及一套适合这份工作的工具。前者不需要第二个 agent,后者可以是多开一个的理由(见下面第 4 种情况)。
- 交接会丢掉理解。就是上面那张图。理解要压缩成摘要才能交出去,而下一个 agent 要动手,光有摘要是不够的。
- 固定规则能决定的事,别交给模型。“下一步谁来做”“做完没有”往往有固定答案。一个小程序每次都能答对,模型只是大多数时候答对。
- 返工要从头来。在我的配置里,每一轮检查都会开一个新的 reviewer,从头再读一遍。
How it works
What a subagent can and cannot do
Think of a subagent as a contractor you send a written brief to:
- It sees only the brief. It cannot read your conversation or your notes.
- It cannot call you back. If the brief is missing something, it guesses or stops.
- It sends back a report, not its understanding. Everything it read stays with it.
So before you split off any work, ask one question: will a short report be enough for the main agent to go on?
If yes, a split can work. If the main agent needs everything the helper understood, do not split. A designer handing work to a developer fails this test: the developer needs everything the designer understood, not a summary of it.
Passing the test is not enough. The split also has to buy something one agent cannot get alone. There are four such things.
1. An independent check
When you proofread your own essay, you read what you meant, not what you wrote. An agent checking its own work has the same problem: its context is full of its own reasoning, and that reasoning leads it past its own mistakes.
A checker who has never seen that reasoning reads only the request and the result. If the result does not match, it sees it. That checker is a reviewer. It has to be a separate agent, because it needs a separate context.
- The author's context holds the request, its own reasoning and the work.
- When it checks itself, its reasoning leads it past its own mistakes.
- The reviewer sees only the request and the work. If they do not match, it notices.
A separate context is needed, but it is not enough. The reviewer is often the same model, with the same blind spots, and it can be wrong: fail good work, or pass bad work. So an independent check lowers the risk; it does not remove it.
How to build a good one:
- Give it a package, not the conversation: the request, the changed files, and the diff (exactly which lines changed). Leave the author's notes out on purpose.
- Take away its tools to change files. It cannot "just fix it", even when it wants to.
- Let it point out, not fix. If it wrote the fix, the next check would be checking its own solution.
- Every finding names a file and a line. What it cannot point to is not a finding. This keeps out vague worries.
- Fix the first line: PASS or FAIL. Then a small program can read the verdict, without asking another AI what the reviewer meant.
- Limit the rounds. A few checks per task; after that, a person decides. From the second round on, report only what affects correctness, or the checks never end over wording.
2. Parallel reading
Some questions need a lot of reading. "What does each of these five areas own, and what are its rules?" One agent would read the five areas one after another. That is slow, and by the end its context is full of raw material it no longer needs.
Instead, the work can be split the way big data jobs are split: map each part to a helper that reads it and writes a short summary, then reduce the summaries into one answer. The method is called map-reduce, and each helper is a mapper. The parts are read at the same time, and the main agent only ever sees the summaries.
- Map: the main agent splits the reading into parts and starts one mapper per part.
- Each mapper reads only its part. They all read at the same time.
- Each hands back a short summary. The raw material stays with the mapper.
- Reduce: the main agent reads only the summaries and combines them into one answer.
This is where several agents clearly win. Anthropic built a research system on this pattern: a lead agent plans, and subagents search different directions at the same time. On their internal research tests it beat a single agent (Claude Opus 4) by 90.2%, and it shines on broad questions that split into independent directions. The price: such systems use about 15 times the tokens of a chat. They also note that most coding tasks have fewer truly parallel parts than research. (How we built our multi-agent research system)
So the test is two questions: does the job split into parts that do not need each other, and is the answer worth several times the cost?
This only works for reading. If several helpers changed the same files at the same time, someone would have to merge their changes, and conflicts hide in a merge.
How to build it:
- The person switches it on, not the agent. It costs several times as much, and that is your decision. A small program counts the helpers (for example, four within an hour), so the agent cannot start more. Only a command the person types counts; the agent cannot type it for itself.
- Each mapper can read and search, nothing else.
- Every brief has three parts: the question, the scope (which files or folders to read, and only those), and what to hand in. Anthropic saw what vague briefs do: helpers duplicate work, leave gaps, or misread the task. Early versions even started 50 subagents for a simple question.
- Every summary has a fixed shape: conclusions, each with the file and line it comes from; what it could not find; what it is not sure of.
3. Work that runs unattended
Normally an agent stops after each step and waits for you. Sometimes you want to hand over a whole to-do list and come back when it is done.
The simplest version needs a hook: a small program that the tool runs at fixed moments. Copilot and Claude Code both have them. Here the moment is "the agent has stopped". The hook looks at the to-do list. If a step is still open, it tells the agent to go on. Only the person can switch this on, for one task at a time.
It also needs to know when to stop pushing. Each stop rule catches a different way it can go wrong:
- A cap on steps and on time (for example, 20 steps or 2 hours): a runaway run cannot spend all night.
- Stop after a few refusals (for example, two): when the agent keeps trying things it is not allowed to do, something is wrong, and a person should look.
- Stop when nothing moves (for example, three pushes in a row with no step done): the agent is stuck in a loop.
In this simplest version, one agent does every step. That is fine for a short list. On a long one, its context fills up with everything from the earlier steps: files it read for step 2, commands it ran for step 5, a test that failed and was fixed. By step 15 it is carrying fourteen steps of leftovers, and an overfull context forgets and mixes things up.
The better version works like a site manager on a building site. The manager does not lay bricks. They keep the plan and the checklist, give each job to a worker on a written job card, and tick the job off when the worker reports back. The manager's head stays clear, because the details of each job stay with the worker who did it.
- You hand over the whole to-do list. The main agent takes your place as the one in charge.
- For step 1 it writes a brief and starts a fresh worker. The worker does the step and its tests.
- The worker reports back in a few lines. The main agent ticks the step off in the task files.
- Every step gets a new worker with an empty context. The main agent holds only the plan, the checklist and the reports.
- When all steps are done, the reviewer checks the whole result.
- You hand over the whole to-do list. The main agent takes your place as the one in charge.
- For each step, the main agent writes a brief (what to do, which files, what "done" looks like, how to test it) and starts a fresh subagent: a worker.
- The worker does the step and its tests, writes down what it did, and reports back in a few lines: done or not, tests passed or not, which files changed.
- The main agent ticks the step off and starts a new worker for the next step. Its own context only ever holds the plan, the checklist and the short reports.
- When every step is done, the reviewer checks the whole result. If it fails, the main agent starts a worker to fix what the reviewer found.
Why does this split work, when the three-role team did not? The team split one piece of work by phase: one agent understood it, and another had to act on that understanding. Here the split is by piece. Each worker gets a whole small job, both the doing and the testing, and the main agent needs only "done, tests pass" to go on. That passes the summary test.
The price:
- Every brief must be complete. The worker cannot ask back, so whatever it needs has to be written down.
- Every worker starts from zero. It reads its files again, so many small steps cost more than one agent doing them in a row.
- A report is not proof. A worker that says "tests pass" may be wrong, and the main agent, seeing only reports, cannot tell. That is why the independent check at the end matters, and why the main agent should open the files of a step now and then.
- Steps that depend on each other's details do not fit. If step 4 needs to know exactly how step 3 was done, either write that down for the next worker or keep both steps with one agent.
So it pays for a long list of steps that each stand on their own. For a short list, one agent is still cheaper. And if you are there to watch, splitting a long task into several smaller tasks gets most of the same benefit.
4. A hard limit on tools
Each agent has a list of tools it may use: read files, search, run commands, change files. In Copilot it is the tools list in an agent file; Claude Code's subagents have one too. The platform enforces that list. An agent without the "change files" tool cannot change a file, however it is asked.
The main agent usually has every tool. If a job must not change anything, telling the main agent "please do not change files" is only a request. Giving the job to a subagent that has no such tool makes it a rule.
Make it a rule, not a request
How do you make sure no other subagent runs? Writing "do not start other subagents" in the instructions is only a request: the model follows it most of the time.
A hook makes it a rule. One that runs just before any subagent starts can read the subagent's name and say yes or no. It runs every time, and the model cannot talk it out of its answer. A good refusal also says what to do instead, so the agent does not try the same thing again.
Hand over through files
Agents should not send each other messages. Give each piece of work its own task folder, holding the request, the plan, the to-do list and the results of every check. Agents hand over by writing files there.
This buys three things at once. You can open the same files and see what happened. If you stop for a day, the next session picks the work up from the files. And afterwards, the folder is a record of who did what and what the checks said.
Test your own setup
Three questions for any extra agent, in your own setup or in a proposal you are asked to approve:
- Which of the four does it buy?
- Will a short report be enough for the main agent to go on?
- Did you try the same task without it?
A test you can run today, with no extra setup. Take a task you know the right answer to. Do it twice in your own tool. Once, ask the agent to check its own work. Once, open a new chat, give it only the request and the result, and ask it to check. Compare what each one found.
To compare two setups fairly:
- Run each one several times, not once. An agent does not do the same thing twice.
- Score both the same way, ideally with a script.
- Write down three numbers: was it right, how much usage, how long.
- Do not decide from a single run.
To repeat my test. The made-up repository, the four tasks and the scoring script are in labs/subagents/. They work with any agent tool.
原理
子 agent 能做什麼、不能做什麼
把子 agent 想成一個你寄了書面說明過去的外包:
- 它只看得到說明。它讀不到你們的對話,也讀不到你的筆記。
- 它不能回頭問你。說明裡少了什麼,它只能猜,或者停下來。
- 它交回的是報告,不是理解。它讀過的東西都留在它那裡。
所以在拆出任何工作之前,先問一個問題:一份簡短的報告,夠不夠主 agent 接著做?
夠,就可以拆。主 agent 要接著做,卻需要幫手的全部理解,就不要拆。設計師把工作交給開發者就過不了這一關:開發者需要的是設計師的全部理解,不是一份摘要。
過了這一關還不夠。拆分還得買到一個 agent 自己得不到的東西。這樣的東西有四種。
1. 獨立檢查
校對自己的文章時,你讀到的是你想寫的,不是你寫出來的。agent 檢查自己的工作也一樣:它的上下文裡全是它自己的思路,這些思路會帶著它繞過自己的錯。
一個從沒看過那些思路的檢查者,只讀需求和結果。結果對不上,它就看得出來。這個檢查者就是 reviewer。它必須是另一個 agent,因為它需要另一個上下文。
- 作者的上下文裡有需求、它自己的思路和做出來的東西。
- 自己檢查自己時,思路會帶著它繞過自己的錯。
- reviewer 只看需求和做出來的東西。兩者對不上,它就會發現。
另一個上下文是必要的,但不夠。reviewer 常常是同一個模型,有同樣的盲點,它也會判錯:把好的判成不通過,把壞的放過去。所以獨立檢查降低風險,但不能消除風險。
怎麼搭一個好的:
- 給它一個檢查包,不給對話。包裡有需求、改過的檔案和 diff(到底改了哪幾行)。作者的筆記故意不給。
- 拿掉它改檔案的工具。就算它想「順手修掉」,也做不到。
- 只讓它指出問題,不讓它修。它寫了修法,下一輪檢查就是在檢查它自己的方案。
- 每個問題都要指到檔案和行號。指不出來的就不算問題。這樣可以擋掉含糊的擔心。
- 第一行固定寫 PASS 或 FAIL。這樣一個小程式就能讀出結論,不用再問另一個 AI「reviewer 是什麼意思」。
- 限制輪數。每個任務檢查幾次就好,之後由人決定。從第二輪起只報影響正確性的問題,不然檢查會為了措辭沒完沒了。
2. 並行閱讀
有些問題要讀很多東西。「這五個領域各自負責什麼?各有什麼規則?」一個 agent 只能一個領域接一個領域地讀。這很慢,而且讀到最後,它的上下文塞滿了已經用不著的原始材料。
換個做法,像處理大數據那樣拆:把每一份 map(分派)給一個幫手,它讀完寫一份簡短的摘要;再把這些摘要 reduce(合併)成一個答案。這個方法叫 map-reduce,每個幫手叫 mapper。幾份同時讀,主 agent 自始至終只看到摘要。
- Map:主 agent 把要讀的東西分成幾份,每份開一個 mapper。
- 每個 mapper 只讀自己那一份,大家同時讀。
- 每個 mapper 交回一份簡短的摘要,原始材料留在它那裡。
- Reduce:主 agent 只讀摘要,把它們合成一個答案。
這正是多個 agent 明顯佔優的地方。Anthropic 用這個模式做了一個研究系統:一個主 agent 做規劃,幾個子 agent 同時往不同方向搜尋。在他們內部的研究評測上,它比單個 agent(Claude Opus 4)好 90.2%,尤其擅長能拆成幾個獨立方向的廣泛問題。代價是:這類系統用的 token 約是聊天的 15 倍。他們也說,大多數寫程式的任務,真正能並行的部分比研究少。(How we built our multi-agent research system)
所以判斷只有兩個問題:這份工作能不能拆成彼此不需要對方的幾部分?答案值不值得好幾倍的成本?
這只適用於讀。幾個幫手同時改同樣的檔案,就得有人合併它們的改動,而衝突會藏在合併裡。
怎麼搭:
- 由人來開,不由 agent 開。它貴好幾倍,該由你決定。一個小程式負責計數(例如一小時內最多四個),agent 開不了更多。只有人輸入的指令才算,agent 不能替自己輸入。
- 每個 mapper 只能讀和搜尋,別的都不行。
- 每份說明都有三部分:問題、範圍(讀哪些檔案或資料夾,只讀這些)、要交回什麼。Anthropic 看到過說明含糊的後果:幫手重複工作、漏掉該查的、誤解任務。早期版本甚至為一個簡單問題開了 50 個子 agent。
- 每份摘要格式固定:結論,每條附上出自哪個檔案、哪一行;找不到的;不確定的。
3. 無人值守
平常 agent 做完一步就停下來等你。有時你想把整份待辦清單交出去,做完再回來看。
最簡單的做法要用到 hook:工具在固定時刻會執行的一個小程式。Copilot 和 Claude Code 都有。這裡的時刻是「agent 停下來了」。hook 看一眼待辦清單,還有沒做完的步驟,就叫 agent 繼續。只有人能開,一次只對一個任務。
它還得知道什麼時候不再推。每條停止規則防的是一種不同的出錯:
- 步數和時間有上限(例如 20 步或 2 小時):失控的執行不會跑一整夜。
- 被拒絕幾次就停(例如兩次):agent 一直在試不准做的事,說明哪裡不對了,該由人來看。
- 沒有進展就停(例如連推三次都沒有完成任何一步):agent 卡在迴圈裡了。
在這個最簡單的做法裡,所有步驟都由一個 agent 做。清單短,沒問題。清單長,它的上下文會塞滿前面每一步留下的東西:第 2 步讀過的檔案、第 5 步跑過的指令、一個失敗後又修好的測試。到第 15 步,它背著前 14 步的殘留,上下文太滿就會忘事、搞混。
更好的做法像工地上的管理者。管理者不砌磚。他手上拿著計劃和清單,把每份活寫在工作卡上交給工人,工人回報後就打勾。管理者腦子一直是清楚的,因為每份活的細節都留在做活的工人那裡。
- 你把整份待辦清單交出去,主 agent 代替你負責。
- 第 1 步:它寫好說明,開一個新的 worker。worker 負責這一步和它的測試。
- worker 用幾行字匯報結果,主 agent 在任務檔案裡把這一步打勾。
- 每一步都換一個上下文是空的新 worker。主 agent 只記著計劃、清單和匯報。
- 所有步驟做完後,reviewer 檢查整體結果。
- 你把整份待辦清單交出去。主 agent 代替你負責。
- 每一步,主 agent 寫一份說明(做什麼、哪些檔案、怎樣算做完、怎麼測),開一個新的子 agent:一個 worker。
- worker 做這一步和它的測試,記下自己做了什麼,用幾行字回報:做完沒有、測試過沒過、改了哪些檔案。
- 主 agent 把這一步打勾,為下一步開一個新的 worker。它自己的上下文裡永遠只有計劃、清單和簡短的回報。
- 全部做完後,reviewer 檢查整體結果。不通過,主 agent 就開一個 worker 去修 reviewer 找到的問題。
三角色團隊不行,為什麼這樣拆就行?團隊是把同一件事按階段拆:一個 agent 搞懂,另一個要接著那份理解去做。這裡是按塊拆:每個 worker 拿到的是一整件小事,做和測都包含在內,主 agent 只需要知道「做完了、測試通過」就能往下走。這過得了摘要那一關。
代價:
- 每份說明都要寫全。worker 不能回頭問,它需要的都得寫下來。
- 每個 worker 都從零開始。它要重讀自己的檔案,所以很多小步驟加起來,比一個 agent 一路做下來貴。
- 回報不是證明。worker 說「測試通過」也可能是錯的,而只看回報的主 agent 分辨不出來。所以最後的獨立檢查很重要,主 agent 也該不時打開某一步的檔案看看。
- 彼此依賴細節的步驟不適合。第 4 步要確切知道第 3 步怎麼做的,就把它寫下來交給下一個 worker,或者乾脆兩步都由一個 agent 做。
所以它適合很長、每一步都能獨立完成的清單。清單短,一個 agent 還是更便宜。要是你人在旁邊,把長任務拆成幾個小任務,也能拿到大部分好處。
4. 工具的硬性限制
每個 agent 都有一份能用的工具清單:讀檔案、搜尋、執行指令、改檔案。在 Copilot 裡,這是 agent 檔案裡的 tools 清單;Claude Code 的子 agent 也有。平台會強制執行這份清單。沒有「改檔案」這個工具的 agent,怎麼叫它都改不了檔案。
主 agent 通常什麼工具都有。一份工作絕不能改任何東西時,跟主 agent 說「請不要改檔案」只是請求。把這份工作交給一個沒有這個工具的子 agent,它才變成規則。
讓它成為規則,而不是請求
怎麼確保不會有別的子 agent 跑起來?在指示裡寫「不要開別的子 agent」只是請求:模型大多數時候會照做。
hook 能把它變成規則。一個在任何子 agent 啟動前執行的 hook,可以讀出子 agent 的名字,決定准或不准。它每次都會執行,模型也說服不了它。好的拒絕還會說明該改做什麼,免得 agent 再試同一件事。
靠檔案交接
agent 之間不該互相傳訊息。給每件工作一個自己的任務資料夾,裡面放需求、計劃、待辦清單和每次檢查的結果。agent 透過把檔案寫進這裡來交接。
這一下買到三樣東西。你能打開同樣的檔案,看到發生了什麼。中斷一天,下一個會話能從檔案接著做。事後,這個資料夾就是一份紀錄:誰做了什麼,檢查怎麼說。
測一測你自己的設定
三個問題,問你自己設定裡的、或別人要你批准的任何一個額外 agent:
- 它買到的是四種裡的哪一種?
- 一份簡短的報告,夠不夠主 agent 接著做?
- 同一個任務,你試過不用它嗎?
今天就能做、不用任何額外設定的測試。挑一個你知道正確答案的任務,在你自己的工具裡做兩遍。一遍讓 agent 檢查自己的工作。另一遍開一個新對話,只給它需求和結果,請它檢查。比一比兩邊各找到了什麼。
公平地比較兩種設定:
- 每種跑幾次,不是一次。agent 不會兩次做出一樣的事。
- 兩邊用同一種方式打分,最好用腳本。
- 記下三個數:對不對、用量多少、花多久。
- 不要憑一次結果下結論。
想重做我的測試:虛構的倉庫、四個任務和打分腳本都在 labs/subagents/,任何 agent 工具都能用。
原理
子 agent 能做什么、不能做什么
把子 agent 想成一个外包,你只给他寄了一份书面说明:
- 它只看得到这份说明。你们之前的对话、你的笔记,它都看不到。
- 它没法回头问你。说明里缺了什么,它只能猜,或者停下来。
- 它交回来的是报告,不是理解。它读过的东西都留在它自己那里。
所以拆出任何一块工作之前,先问一个问题:一份简短的报告,够不够主 agent 接着干?
够,就可以拆。如果主 agent 要接着干,却需要帮手的全部理解,那就别拆。设计师把活交给开发者,就过不了这一关:开发者要的是设计师的全部理解,不是一份摘要。
过了这一关还不够。拆分还必须换来一个 agent 自己拿不到的东西。这样的东西有四种。
1. 独立检查
自己校对自己的文章时,你读到的是你想写的,而不是你实际写出来的。agent 检查自己的工作也一样:它的上下文里全是自己的思路,这些思路会带着它绕过自己犯的错。
一个从没见过这些思路的检查者,只读需求和结果。两者对不上,它就能看出来。这个检查者就是 reviewer。它必须是另一个 agent,因为它需要另一份上下文。
- 作者的上下文里有需求、它自己的思路和做出来的东西。
- 自己检查自己时,思路会带着它绕过自己犯的错。
- reviewer 只看需求和做出来的东西。两者对不上,它就能发现。
另一份上下文是必要条件,但不是充分条件。reviewer 往往是同一个模型,有同样的盲区,它也会误判:把好的判成不通过,把坏的放过去。所以独立检查能降低风险,但消除不了风险。
怎么搭一个好用的:
- 给它一个检查包,别给对话。包里有需求、改过的文件和 diff(到底改了哪几行)。作者的笔记故意不给。
- 拿掉它改文件的工具。就算它想“顺手修一下”,也做不到。
- 只让它指出问题,不让它修。它要是写了修法,下一轮检查就成了检查它自己的方案。
- 每个问题都要指到文件和行号。指不出来的不算问题。这样能挡掉那些含糊的担心。
- 第一行固定写 PASS 或 FAIL。这样一个小程序就能读出结论,不用再找另一个 AI 来解读“reviewer 这是什么意思”。
- 限制轮数。每个任务检查几次就够了,之后交给人决定。从第二轮开始只报影响正确性的问题,不然检查会在措辞上没完没了。
2. 并行阅读
有些问题需要读很多东西。“这五个领域各管什么?各有什么规则?”一个 agent 只能一个领域接一个领域地读。这很慢,而且读到最后,它的上下文里塞满了已经用不上的原始材料。
换个办法,像处理大数据那样拆:把每一份 map(分发)给一个帮手,它读完写一份简短的摘要;再把这些摘要 reduce(汇总)成一个答案。这个方法叫 map-reduce,每个帮手叫 mapper。几份同时读,主 agent 从头到尾只看到摘要。
- Map:主 agent 把要读的东西分成几份,每份开一个 mapper。
- 每个 mapper 只读自己那一份,大家同时读。
- 每个 mapper 交回一份简短的摘要,原始材料留在它自己那里。
- Reduce:主 agent 只读摘要,把它们汇总成一个答案。
这正是多 agent 明显占优的地方。Anthropic 用这个模式做了一个研究系统:一个主 agent 负责规划,几个子 agent 同时朝不同方向搜索。在他们内部的研究评测上,它比单个 agent(Claude Opus 4)好 90.2%,尤其擅长那种能拆成几个独立方向的大范围问题。代价是:这类系统消耗的 token 约是普通聊天的 15 倍。他们也说,大多数编程任务里真正能并行的部分比研究少。(How we built our multi-agent research system)
所以判断起来只有两个问题:这份工作能不能拆成互不依赖的几块?答案值不值好几倍的成本?
这只适用于读。几个帮手同时改同一批文件,就得有人合并它们的改动,冲突会藏在合并里。
怎么搭:
- 由人来开,不让 agent 开。它贵好几倍,该你来拍板。一个小程序负责计数(比如一小时内最多四个),agent 开不了更多。只有人输入的命令才算数,agent 不能替自己输入。
- 每个 mapper 只能读和搜索,别的都不行。
- 每份说明都包含三部分:问题、范围(读哪些文件或文件夹,只读这些)、要交回什么。Anthropic 见过说明写得含糊的后果:帮手之间重复干活、漏查该查的、理解错任务。早期版本甚至为一个简单的问题开了 50 个子 agent。
- 每份摘要格式固定:结论,每条注明出自哪个文件、哪一行;没找到的;不确定的。
3. 无人值守
平时 agent 做完一步就停下来等你。有时候你想把整张待办清单交出去,等它做完再回来看。
最简单的做法要用到 hook:工具在固定时机会运行的一个小程序。Copilot 和 Claude Code 都有。这里的时机是“agent 停下来了”。hook 看一眼待办清单,还有没做完的步骤,就让 agent 继续。只有人能开启,一次只针对一个任务。
它还得知道什么时候别再推了。每条停止规则防的是一种不同的故障:
- 步数和时间有上限(比如 20 步或 2 小时):失控的运行不会跑一整夜。
- 被拒绝几次就停(比如两次):agent 一直在尝试不许做的事,说明哪里出了问题,该让人来看看。
- 没有进展就停(比如连推三次都没完成任何一步):agent 陷在循环里了。
在这个最简单的做法里,所有步骤都由一个 agent 来做。清单短,没问题。清单一长,它的上下文就会塞满前面每一步留下的东西:第 2 步读过的文件、第 5 步跑过的命令、一个先失败后修好的测试。到第 15 步时,它背着前 14 步的残留,上下文太满,就会忘事、搞混。
更好的做法像工地上的项目经理。项目经理不亲自砌砖。他手里拿着图纸和清单,把每份活写在任务单上交给工人,工人回报后他就打个勾。项目经理的脑子一直是清醒的,因为每份活的细节都留在干活的工人那里。
- 你把整张待办清单交出去,主 agent 替你盯着。
- 第 1 步:它写好说明,开一个新的 worker。worker 负责这一步和对应的测试。
- worker 用几行字回报结果,主 agent 在任务文件里给这一步打勾。
- 每一步都换一个上下文空白的新 worker。主 agent 只记着计划、清单和回报。
- 所有步骤做完后,reviewer 检查整体结果。
- 你把整张待办清单交出去。主 agent 替你盯着。
- 每一步,主 agent 写一份说明(做什么、涉及哪些文件、怎样算做完、怎么测),开一个新的子 agent:一个 worker。
- worker 完成这一步和对应的测试,记下自己做了什么,用几行字回报:做完没有、测试过没过、改了哪些文件。
- 主 agent 给这一步打勾,为下一步开一个新的 worker。它自己的上下文里始终只有计划、清单和简短的回报。
- 全部做完后,由 reviewer 检查整体结果。不通过,主 agent 就开一个 worker 去修 reviewer 找出的问题。
三角色团队行不通,为什么这样拆就行?团队是把同一件事按阶段拆:一个 agent 负责弄懂,另一个要接着这份理解去干。这里是按块拆:每个 worker 拿到的是一件完整的小事,干活和测试都包在里面,主 agent 只要知道“做完了,测试通过”就能往下走。这能过摘要那一关。
代价:
- 每份说明都得写全。worker 没法回头问,它需要的都得写下来。
- 每个 worker 都从零开始。它要重新读自己那部分文件,所以很多小步骤加起来,比一个 agent 一路做到底更贵。
- 回报不等于证明。worker 说“测试通过”也可能是错的,只看回报的主 agent 分辨不出来。所以最后的独立检查很重要,主 agent 也该时不时打开某一步的文件看一眼。
- 步骤之间互相依赖细节的,不合适。第 4 步需要确切知道第 3 步是怎么做的,那就把它写下来交给下一个 worker,或者干脆两步都交给一个 agent。
所以它适合那种很长、每一步都能独立完成的清单。清单短,一个 agent 还是更便宜。如果你人就在旁边,把长任务拆成几个小任务,也能拿到大部分好处。
4. 工具的硬性限制
每个 agent 都有一份能用的工具清单:读文件、搜索、跑命令、改文件。在 Copilot 里,这是 agent 文件里的 tools 列表;Claude Code 的子 agent 也有。平台会强制执行这份清单。一个没有“改文件”工具的 agent,你怎么让它改,它都改不了。
主 agent 通常什么工具都有。某项工作绝对不能改任何东西时,跟主 agent 说“请不要改文件”只是一个请求。把这项工作交给一个没有这个工具的子 agent,它才成了规则。
让它成为规则,而不是请求
怎么保证不会有别的子 agent 跑起来?在指令里写“不要开其他子 agent”只是请求:模型大多数时候会照做。
hook 能把它变成规则。一个在任何子 agent 启动前运行的 hook,可以读出子 agent 的名字,决定放行还是拒绝。它每次都会运行,模型也说服不了它。好的拒绝还会说明应该改做什么,免得 agent 再去试同一件事。
靠文件交接
agent 之间不该互相发消息。给每件工作建一个自己的任务文件夹,里面放需求、计划、待办清单和每次检查的结果。agent 通过往这里写文件来交接。
这一招换来三样东西。你能打开同样的文件,看到发生了什么。中断一天,下一个会话能从文件接着做。事后,这个文件夹就是一份记录:谁做了什么,检查结论是什么。
用它检验你自己的配置
三个问题,拿去问你自己配置里的、或者别人找你审批的任何一个额外 agent:
- 它换来的是四种里的哪一种?
- 一份简短的报告,够不够主 agent 接着干?
- 同一个任务,你试过不用它吗?
今天就能做、不需要任何额外配置的测试。挑一个你知道正确答案的任务,在你自己的工具里做两遍。一遍让 agent 检查自己的工作。另一遍新开一个对话,只给它需求和结果,让它来检查。对比一下两边各找出了什么。
公平地对比两种配置:
- 每种跑几次,不要只跑一次。agent 不会两次做得一模一样。
- 两边用同一种方式打分,最好用脚本。
- 记下三个数:对不对、用了多少、花了多久。
- 别凭一次结果下结论。
想复现我的测试:虚构的仓库、四个任务和打分脚本都在 labs/subagents/,任何 agent 工具都能用。
Costs and traps
How sure I am. Sure of the direction, not of the exact ratio. Two reasons:
- Each task ran once. Run it again and the numbers move.
- The two sides were not equal. The single agent used a top model and had no extra setup. The team had a knowledge base to read. Each difference could push the numbers either way.
A gap of four to six times is large enough to take seriously. To be sure of it, the test has to be run several times.
What I did not measure. A vague request in a very large, messy repository. That is where splitting might pay off. I have no data either way.
What the extra money did buy. Once, the builder missed two references across areas. The reviewer caught them and sent the work back, with no person stepping in. That is why I kept the reviewer when the rest of the team went.
Parallel reading is not free. Every mapper starts from an empty context and reads its part from zero. Four mappers cost several times one agent. Use it when the reading is too much for one context, not to save time on a few files.
Subagent usage is easy to miss. A tool often shows the usage of the main conversation only. Check whether yours counts subagents too.
A count is not a budget. Limiting how many helpers start does not limit what they spend together. The better design gives the main agent and all its subagents one budget, and a subagent gets what is left of it, not a fresh one of its own.
代價和陷阱
我有多確定。確定方向,不確定確切的倍數。兩個原因:
- 每個任務只跑了一次。再跑一次,數字就會變。
- 兩邊不對等。單個 agent 用的是頂級模型,沒有額外設定;團隊多了一份知識庫可讀。每個差別都可能把數字往任一邊推。
四到六倍的差距,大到值得認真對待。要確定它,得多跑幾次。
我沒測的。一個含糊的需求,配上一個很大、很亂的倉庫。拆分也許在那裡划算。我兩邊都沒有資料。
多花的錢確實買到了什麼。有一次,實作者漏改了兩處跨領域的引用。reviewer 抓到了,把工作退回去,全程沒有人插手。所以團隊的其他角色都撤了,我留下了 reviewer。
並行閱讀不是免費的。每個 mapper 都從空的上下文開始,從零讀自己那一份。四個 mapper 的成本是一個 agent 的好幾倍。要讀的東西一個上下文裝不下時才用它,別為了幾個檔案省時間。
子 agent 的用量很容易漏看。工具常常只顯示主對話的用量。看看你的工具有沒有把子 agent 也算進去。
計數不等於預算。限制開幾個幫手,不等於限制它們一共花多少。更好的設計是讓主 agent 和所有子 agent 共用一個預算,子 agent 拿到的是剩下的部分,而不是自己另起一份。
代价和坑
我有多大把握。方向有把握,具体倍数没把握。原因有两个:
- 每个任务只跑了一次。再跑一次,数字就会变。
- 两边条件不对等。单个 agent 用的是顶级模型,没加额外配置;团队多了一份知识库可读。每个差异都可能把数字往任意一边推。
四到六倍的差距,大到值得认真对待。要坐实它,得多跑几次。
我没测的。一个含糊的需求,加上一个又大又乱的仓库。拆分在那种场景下也许划算。两边我都没有数据。
多花的钱确实换来了一点东西。有一次,开发者漏改了两处跨领域的引用。reviewer 发现了,把活打回去重做,全程没人插手。所以团队里的其他角色都撤了,我留下了 reviewer。
并行阅读不是免费的。每个 mapper 都从空白的上下文开始,从头读自己那一份。四个 mapper 的成本是一个 agent 的好几倍。只有要读的东西一份上下文装不下时才用它,别为了几个文件省点时间就上。
子 agent 的用量很容易被漏掉。工具往往只显示主对话的用量。看看你的工具有没有把子 agent 也算进去。
限制个数不等于限制预算。限制能开几个帮手,不等于限制它们一共花多少。更好的设计是让主 agent 和所有子 agent 共用一份预算,子 agent 拿到的是剩下的部分,而不是自己另起一份。
What the industry says Industry practice
The platform makers agree on the direction: more agents, many more tokens.
- Anthropic's research system (above): about 15 times the tokens of a chat, worth it for broad research, less so for most coding. (How we built our multi-agent research system)
- Claude Code has agent teams: several agents that act as a team and message each other. Its docs say they "use approximately 7x more tokens than standard sessions when teammates run in plan mode" (plan mode: each teammate plans before it acts). That is a different setup from my test, so the numbers do not compare directly. Agent teams are experimental and off by default. (Manage costs)
- VS Code: "Keep agent chains as shallow as practical and limit tools to what each agent actually needs." (Context engineering guide)
None of them says one agent is always better. Together with my test: for one task with a clear request, do not orchestrate; for broad work that splits into independent parts, several agents can be worth their cost.
業界怎麼說 業界做法
平台廠商在方向上一致:agent 越多,token 多得越多。
- Anthropic 的研究系統(見上文):token 約是聊天的 15 倍,做廣泛的研究值得,大多數寫程式的任務就沒那麼值得。(How we built our multi-agent research system)
- Claude Code 有 agent teams:幾個 agent 組成團隊、互相傳訊息。它的文件說,「teammates 在 plan mode 下執行時,token 用量約是一般會話的 7 倍」(plan mode:每個成員先規劃再動手)。這和我的測試設定不同,數字不能直接比。agent teams 是實驗功能,預設關閉。(Manage costs)
- VS Code:「讓 agent 鏈盡量淺,每個 agent 只給它真正需要的工具。」(Context engineering guide)
沒有一家說一個 agent 永遠比較好。加上我的測試:需求清楚的單一任務,不要編排;能拆成獨立幾部分的廣泛工作,多個 agent 可能值得它的成本。
业界怎么说 业界做法
平台厂商在方向上是一致的:agent 越多,token 多得越多。
- Anthropic 的研究系统(见上文):token 约是普通聊天的 15 倍,用来做大范围的研究值得,用在大多数编程任务上就没那么值。(How we built our multi-agent research system)
- Claude Code 有 agent teams:几个 agent 组成团队、互相发消息。它的文档说,“当 teammates 在 plan mode 下运行时,token 用量约是普通会话的 7 倍”(plan mode:每个成员先规划再动手)。这和我的测试配置不一样,数字不能直接比。agent teams 是实验功能,默认关闭。(Manage costs)
- VS Code:“让 agent 链尽量浅,每个 agent 只给它真正需要的工具。”(Context engineering guide)
没有哪一家说一个 agent 永远更好。再加上我的测试:需求清楚的单个任务,别搞编排;能拆成几块独立工作的大范围任务,多 agent 可能值这个成本。
When to delete it Industry practice
The hooks in this chapter (allow only named subagents, count the helpers, push an unattended run) exist because the platform does not do these things yet. When Copilot itself can allow only named subagents and cap the usage of the main agent and all its subagents together, drop the hooks.
The reasoning does not retire with them. Two things would make me look again at the split itself:
- The platform can resume a finished subagent. Rework would stop starting from zero, and a thin coordinator inside one task might pay off. I have not tested whether Copilot can do this today.
- A comparison shows a self-check catches everything an independent check catches. Then even the reviewer can go.
什麼時候可以刪掉 業界做法
這一章裡的 hook(只准指定的子 agent、替幫手計數、推動無人值守的執行)之所以存在,是因為平台還不做這些事。等 Copilot 自己能只准指定的子 agent,並且能給主 agent 和所有子 agent 的用量設一個總上限,就刪掉這些 hook。
背後的道理不會跟著退役。有兩件事會讓我重新考慮拆分本身:
- 平台能接著用一個做完的子 agent。返工就不用從零開始,一個任務裡放一個很薄的協調者也許就划算了。Copilot 今天能不能做到,我還沒測過。
- 一次比較顯示,自我檢查能抓到獨立檢查抓到的一切。那麼連 reviewer 都可以撤掉。
什么时候可以删掉 业界做法
这一章里的 hook(只放行指定的子 agent、给帮手计数、推动无人值守的运行)之所以存在,是因为平台还不做这些事。等 Copilot 自己能只放行指定的子 agent,并且能给主 agent 和所有子 agent 的用量设一个总上限,就把这些 hook 删掉。
背后的道理不会跟着退役。有两件事会让我重新考虑拆分本身:
- 平台能让一个做完的子 agent 接着干。返工就不用从头开始,在一个任务里放一个很轻的协调者也许就划算了。Copilot 现在能不能做到,我还没测过。
- 一次对比表明,自我检查能抓到独立检查能抓到的所有问题。那就连 reviewer 也可以撤了。
Try it on your own setup
No harness needed. Open your agent in your own repository and paste:
List every custom agent, subagent or role this project defines (look in the agent and instruction files). For each one, tell me which of these it buys: an independent check, parallel work, work that runs unattended, or a hard limit on tools. Mark any that buys none of them, and say what would break if it were removed. Do not change any files.在你自己的環境試試
不用裝 harness。在你自己的倉庫裡打開 agent,貼上:
列出這個專案定義的所有自訂 agent、子 agent 或角色(看 agent 檔和 instructions 檔)。每一個都告訴我它買到下面哪一樣:獨立檢查、並行、無人值守、工具的硬限制。哪一個都沒買到的標出來,並說明拿掉它會壞掉什麼。不要改任何檔案。在你自己的环境里试试
不用装 harness。在你自己的仓库里打开 agent,粘贴:
列出这个项目定义的所有自定义 agent、子 agent 或角色(看 agent 文件和 instructions 文件)。逐个告诉我它换来的是下面哪一样:独立检查、并行、无人值守、工具的硬性限制。哪一样都没换来的标出来,并说明拿掉它会坏掉什么。不要修改任何文件。Go deeper
- Anthropic: How we built our multi-agent research system
- Claude Code docs: Manage costs
- VS Code docs: Context engineering guide
延伸閱讀
- Anthropic:How we built our multi-agent research system
- Claude Code 文件:Manage costs
- VS Code 文件:Context engineering guide
延伸阅读
- Anthropic:How we built our multi-agent research system
- Claude Code 文档:Manage costs
- VS Code 文档:Context engineering guide
You can stop here: that is the whole idea. The next part shows where it runs, so you can look inside.讀到這裡就夠了,這就是整個想法。下一部分告訴你它在哪裡運行,可以進去看看。读到这里就够了,核心思路就是这些。下一部分告诉你它在哪里跑,可以进去看看。
In my practice (Copilot Harness)實作实战
Copilot Harness is my open-source harness for VS Code Copilot.
Repository: https://github.com/Smars-Bin-Hu/copilot-agentic-harness
Get started: clone it, open it in VS Code, and type /harness-rookie-get-me-ready in Copilot Chat. You need Python 3.9 or later and git.
Copilot Harness 是我開源的 VS Code Copilot harness。
倉庫: https://github.com/Smars-Bin-Hu/copilot-agentic-harness
開始:clone 下來,用 VS Code 打開,在 Copilot Chat 裡輸入 /harness-rookie-get-me-ready。需要 Python 3.9 以上和 git。
Copilot Harness 是我开源的 VS Code Copilot harness。
仓库: https://github.com/Smars-Bin-Hu/copilot-agentic-harness
上手:把仓库 clone 下来,用 VS Code 打开,在 Copilot Chat 里输入 /harness-rookie-get-me-ready。需要 Python 3.9 及以上版本和 git。
Explore it in the harness
Most of this chapter runs in Copilot Harness: the reviewer, parallel reading, the simplest unattended run, the tool limits, the hook that refuses other subagents, and the task folder. The harness can teach it to you from the inside, with the real files and code. After the setup above, type:
/harness-rookie-wondering I have read the chapter "Use subagents sparingly". Teach me how this harness builds what it describes: subagents (topic 10), independent checks (topic 11), and the unattended run (autorun). For each one, open the real files and code with me, and draw how the pieces fit together.It teaches one small piece at a time, stops to ask if you are following, and opens the files with you.
在 harness 裡探索
這一章的大部分內容都在 Copilot Harness 裡運行:reviewer、並行閱讀、最簡單的無人值守、工具限制、拒絕其他子 agent 的 hook,以及任務資料夾。harness 可以從裡面教你,帶著真實的檔案和程式碼。照上面的說明準備好之後,輸入:
/harness-rookie-wondering 我讀完了「慎用子 agent」這一章。請教我這個 harness 怎麼實作章裡講的東西:子 agent(主題 10)、獨立檢查(主題 11),以及無人值守的執行(autorun)。每一項都帶我打開真實的檔案和程式碼,並畫出各部分怎麼接在一起。它一次教一小塊,停下來確認你跟得上,然後和你一起打開檔案。
在 harness 里探索
这一章的大部分内容都在 Copilot Harness 里跑着:reviewer、并行阅读、最简单的无人值守、工具限制、拒绝其他子 agent 的 hook,以及任务文件夹。harness 可以从内部教你,配上真实的文件和代码。按上面的说明准备好之后,输入:
/harness-rookie-wondering 我读完了“慎用子 agent”这一章。请教我这个 harness 是怎么实现章里讲的东西的:子 agent(主题 10)、独立检查(主题 11),以及无人值守的运行(autorun)。每一项都带我打开真实的文件和代码,并画出各部分是怎么连起来的。它一次只教一小块,停下来确认你跟上了,再和你一起打开文件。