6.3
Fixed tasks, scored by a script固定的任務,用腳本打分固定的任务,用脚本打分
This chapter assumes you have used an AI coding agent, and that you have changed its rules or setup at least once. Nothing else.
讀這一章,你需要用過 AI 寫程式的 agent,而且至少改過一次它的規則或設定。不需要別的。
读这一章,你需要用过一个写代码的 AI agent,并且至少改过一次它的规则或配置。别的都不需要。
The Knowledge經驗分享经验分享
In one sentence
To know whether a change helped, run the same fixed tasks before and after the change and score them with a script. Then read the runs that failed.
一句話
要知道一個改動有沒有幫助,就在改動前後,跑同樣的固定任務,用腳本打分。然後讀失敗的那幾次運行。
一句话
想知道一个改动有没有用,就在改动前后,对同样的固定任务各跑一遍,用脚本打分。然后去读失败的那几次运行。
For leaders
- The decision: require that a change to the agent's rules or setup comes with a before-and-after run on the same fixed tasks, scored by a script.
- The risk: you cannot tell from one good result whether a change helped. My own set is four tasks: enough to show a gap of four to six times, not a gap of ten percent.
- The cost of doing it right: an afternoon to build the scorer and test it on a good answer and a broken one, then the cost of every run. In my lab the three-role team took about 16 minutes and about 456 AI credits for four tasks, once.
- Ask the team: "Which fixed tasks did you run before and after this change, and how do you know the script that scores them catches a wrong answer?"
給主管
- 要做的決定:要求對 agent 的規則或設定做的改動,都要附上改動前後在同樣固定任務上的運行,並用腳本打分。
- 風險:光看一個好結果,你分辨不出改動有沒有幫助。我自己的這組是四個任務:足以顯示四到六倍的差距,顯示不出百分之十的差距。
- 做對的成本:一個下午,建評分腳本,並用一個好答案和一個壞答案測試它;再加上每一次運行的成本。在我的實驗裡,三角色團隊做四個任務,一次大約 16 分鐘、大約 456 個 AI credits。
- 可以問團隊:「這個改動前後,你們跑了哪些固定任務?你們怎麼知道給它們打分的腳本,抓得到錯的答案?」
写给管理者
- 要拍板的事:要求对 agent 规则或配置的改动,必须附上在同一组固定任务上改动前后各跑一遍的结果,由脚本打分。
- 风险:光看一次结果好,你分不出改动有没有用。我自己这套只有四个任务:够看出四到六倍的差距,看不出一成的差距。
- 做对的代价:花一个下午写打分脚本,并用一个好答案和一个故意弄坏的答案测它,然后是每次运行的开销。在我的实验里,三角色团队做完四个任务,一次约 16 分钟、约 456 AI credits。
- 可以问团队:“这个改动前后,你们跑了哪些固定任务?你们怎么知道给它们打分的脚本能抓出错误答案?”
The problem
You add a rule. You change a prompt. You switch on a check. The next task goes well. Did the change help?
You cannot tell. The next task may have been easy. The agent may have done well by luck (the next chapter is about that). And you are not a neutral judge: you made the change and you want it to work. Looking at a result and feeling that it is better is not evidence.
Here is what I did instead for Use subagents sparingly. I wanted to know whether three job-title agents were better than one agent. I did not take one task and look. I took four fixed tasks, ran both setups on each (once each), and let the same script score all of the results. The result changed my design: the team cost far more and got nothing more right (the numbers are in that chapter, with their limits). I would not have believed it from looking at a few results.
Three words first.
- An eval (short for evaluation) is a test for an agent setup: a set of tasks, a way to run them, and a way to score the results.
- A fixed task is a task whose request, starting files and right answer do not change between runs.
- A grader is whatever scores a result: here, mostly a script.
問題
你加了一條規則。你改了一個 prompt。你打開了一個檢查。下一個任務做得很順利。是改動有幫助嗎?
你分辨不出來。下一個任務可能本來就簡單。agent 也可能只是運氣好(下一章 就講這個)。而且你不是中立的評審:改動是你做的,你希望它有用。看著一個結果,覺得變好了,這不是證據。
我在 慎用子 agent 時,是這樣做的。我想知道,三個有職稱的 agent,是不是比一個 agent 好。我沒有拿一個任務來看看。我拿了四個固定任務,兩種設定各跑一次,再讓同一個腳本替所有結果打分。結果改變了我的設計:團隊花的錢多得多,卻沒有多做對任何一件事(數字在那一章,連同它們的限制)。光看幾個結果,我不會相信這一點。
先交代三個詞。
- 評測(eval,evaluation 的縮寫)是對 agent 設定的測試:一組任務、一種執行它們的方法、一種為結果打分的方法。
- 固定任務是這樣的任務:要求、起始檔案和正確答案,在每次運行之間都不變。
- 評分器(grader)是為結果打分的東西:這裡主要是腳本。
问题
你加了一条规则。你改了一个 prompt。你打开了一项检查。下一个任务做得不错。是改动起了作用吗?
你分不出来。下一个任务可能本来就简单。agent 可能是运气好(下一章讲的就是这个)。而且你不是中立的裁判:改动是你做的,你希望它有用。看着一个结果,觉得它变好了,这不是证据。
我在慎用子 agent里是这么做的。我想知道三个岗位的 agent 是不是比一个 agent 强。我没有拿一个任务看一眼。我拿了四个固定任务,每个任务两种配置各跑一次,所有结果交给同一个脚本打分。结果改变了我的设计:团队贵了好多,却没多做对任何一个(数字和它们的局限在那一章里)。光看几个结果,我是不会信的。
先交代三个词。
- 评测(eval,evaluation 的简称)是对 agent 配置的测试:一组任务、一种运行它们的方式、一种给结果打分的方式。
- 固定任务是指需求、起始文件和正确答案在多次运行之间都不变的任务。
- 打分器(grader)是给结果打分的东西:这里主要是脚本。
How it works
The method has four steps. The picture shows them; the sections below say how to do each well.
- Write down a small set of fixed tasks, each with a known right answer. They do not change between runs.
- Run the same tasks before the change and after it, in the same way.
- A script reads the results and scores each item, pass or fail. The same script, every time.
- Compare the two score sheets. Did the change help, hurt, or do nothing?
- Then read the runs that failed. The score says that something failed; reading says why.
What a good task looks like
Not every task makes a good eval. I look for three things.
- It is real. It should look like the work the agent does for you, not like an exam question. If you only ever add pipelines and fix formulas, do not test poetry. A change that helps on made-up work and not on yours teaches you nothing.
- It has one right answer you can check. "Add a pipeline" is checkable: five files exist, in the right places, and agree with each other. "Make the code nicer" is not. If two reasonable people would disagree on whether the result is right, a script cannot score it.
- It covers the mistakes people actually make. A good set has an easy case, and also the traps. In my lab, one task asks the agent to change a file that the rules forbid it to change. A good result is to refuse. That task is there because a real request can ask for exactly that, and an agent that obeys it has done wrong.
The four tasks of my lab are small to medium: add a pipeline; pass a column downstream through three pipelines (one column is renamed on the way); rename a pipeline across areas and delete its old files; fix a formula that lives in two places, where the request also asks to change a protected file. Four is few. It suggested a gap of four to six times, and it would not show a gap of ten percent.
Tasks of this kind come in two sorts. A capability task checks something the setup cannot do yet, so you expect it to fail often at first. A regression task checks something that already works, so you expect it to pass every time, and a failure means a change broke it. Mix the two on purpose, and read a pass rate differently for each.
The repository is made up (93 files, 5 areas) and cannot be run. That is a choice. The right answers are known in advance, so the script can say which result is right, and nobody needs to run code to find out.
Outcome or process?
There are two things a grader can look at.
- The outcome: the files the agent left behind. Did it add the five files? Does the registry list the new pipeline? Is the protected file untouched?
- The process: what the agent did to get there. Did it get refused? Did it write to a place before the plan was approved?
For most tasks, grade the outcome. There are usually many valid ways to reach a right answer, and a grader that insists on one path marks good work as wrong. Grade the process only when the process is the thing you care about, such as "the rules refuse a write before the plan is approved". In my harness, those scenarios look at two things: the log must show the refusal, and the file must be unchanged. The log is why recording every call comes first.
In my lab's scoring, the outcome is a checklist. Some items are the same for every task: the repository is still consistent (valid files, every pipeline has its five files, columns agree, the protected area is untouched). Some are for one task: the request itself is done. One more checks the scope: only the files that should change were changed. A task passes only when every item passes. That is all-or-nothing; if you want to see progress on a long task, score it in parts (partial credit), and report the parts. For a short task like these, one wrong item usually means a wrong result, so I do not split.
A script or a model as the grader
A script reads the files and answers pass or fail. A model can read the result and give a judgment. Each has a weak side.
- A script is cheap, quick and gives the same answer every time. Its weakness is that it is brittle: it can mark a valid result wrong because it looks for one particular form. You find those by reading failures.
- A model grader can accept valid variations and judge things a script cannot, such as whether an explanation is clear. But its answer can change from run to run, and it can share blind spots with the agent it grades (Can a model check a model?).
Anthropic's advice agrees: "We recommend choosing deterministic graders where possible, LLM graders where necessary or for additional flexibility." (Demystifying evals for AI agents) I use a script wherever the answer can be checked in files, and I keep a model grader for the few things a script cannot see. The lab here has no model grader.
Prove the grader first
A grader is a program, and programs have bugs. A grader that passes everything makes every change look harmless. A grader that fails everything makes every change look harmful. So before I trust any score, I test the grader. My lab has a self-test with three parts:
- The untouched repository must fail every task (nothing was done).
- The right answers, written by hand, must pass every task.
- Broken versions of the right answers must all be caught. There are 23, each with one mistake such as a missing registry line or a wrong column. If the grader lets one pass, the grader is wrong.
The smallest version is one good answer and one answer you broke by hand: the grader must pass the first and catch the second. For my lab it took an afternoon, and it is the part people skip. It is also the reason I can say that a failed item means something.
Read the failed runs
Here is a habit I do not give up, even with a script. When a run fails, I open it and read what happened. The score says that something failed. It does not say why, and the why can be one of three very different things:
- The agent made a real mistake. That is what the eval is for.
- The grader is wrong. The result was right, but in a form the script did not expect.
- The task is unclear. Two answers were reasonable, and the request did not say which.
Only the first one tells you about the agent. If you take every failure as the first kind, you will throw away good changes and keep bad ones. Anthropic puts it this way: "Reading transcripts is how you verify that your eval is measuring what actually matters." (the same article)
So the script does not replace looking. It replaces looking at everything, with a guess about what to look at. The script picks the runs that failed. A person then reads those.
Your tasks and public benchmarks
A benchmark is a public set of tasks, scored the same way for everyone, so models can be compared. Benchmarks are useful for one question: how does this model do on someone else's tasks? They cannot answer a different one: did my change to my setup help on my work? For that you need tasks from your repository, and your rules, such as the protected file in my lab. That is why I build my own.
The cost of my own is that it is small, it is mine, and it goes stale. When the repository changes, the tasks must change.
What my harness does today
In my setup there are a few fixed scenarios. Each one is a prompt plus what is expected: a few calls that must appear in the log (such as a refusal) and a few files that must or must not change. I run a scenario by hand once, in Copilot, and a check reads the log and the files and says whether it went right. At the time of writing (October 2026), in my own setup I see that the non-interactive mode of Copilot does not run hooks, so I cannot run the scenarios in a batch, and a before-and-after comparison on real tasks is not done yet. What I have done with numbers is the lab in this repository. In daily use that is one scenario run by hand and a look at the log it leaves. The scored, repeated comparison of this chapter is the lab.
Run it yourself
The lab is the test behind the numbers in Use subagents sparingly: the made-up repository, the four tasks and the scoring script. It works with any agent tool. labs/subagents/ says how to run the self-test first and then your own comparison. Replace the tasks with tasks of your own once you see how it works.
Test your own setup
Three questions for any change you are about to make to an agent setup:
- What would I see if this change helped, and what if it did not?
- Can a script tell the two apart?
- Does the script itself pass the untouched, right and broken test?
A small start, with no tools. Pick three tasks you have done with your agent. For each, write down the files you would expect in the end, and one mistake you have seen. Write a short script that checks the files. (If your work is not code, check the output instead: the columns of a table, the row count, a total.) Run it on a good result and on a result you break by hand. If it catches the broken one and passes the good one, you have an eval. It is small. Use it the next time you change a rule.
原理
方法有四步。圖裡有;下面的小節說每一步怎麼做好。
- 寫下一小組固定任務,每個都有已知的正確答案。每次運行之間不變。
- 改動之前和之後,用同樣的方式跑同一組任務。
- 腳本讀結果,逐項打分,過或不過。每次都是同一個腳本。
- 比較兩份成績單。改動是有幫助、有壞處,還是沒差?
- 然後讀失敗的運行。分數告訴你有東西失敗了;讀過才知道為什麼。
好的任務長什麼樣
不是每個任務都適合做評測。我找三樣東西。
- 它是真的。它應該像 agent 平常替你做的工作,不是像考試題。如果你只加 pipeline、修公式,就不要測寫詩。一個改動在虛構的工作上有幫助、在你的工作上沒有,什麼也教不了你。
- 它有一個你能檢查的正確答案。「加一個 pipeline」可以檢查:五個檔案存在、位置對、彼此一致。「讓程式碼更漂亮」不行。如果兩個講理的人會對結果對不對有不同意見,腳本就沒辦法打分。
- 它涵蓋人真的會犯的錯。好的一組有簡單的案例,也有陷阱。在我的實驗裡,有一個任務要求 agent 改一個規則禁止它改的檔案。好的結果是拒絕。這個任務在這裡,是因為真實的要求可能就是這樣要求,而照做的 agent 就是做錯了。
我的實驗的四個任務,從小到中等:加一個 pipeline;把一個欄位經過三個 pipeline 往下游傳(其中一個欄位途中改了名);跨區域重新命名一個 pipeline 並刪掉舊檔案;修一個存在兩個地方的公式,而要求裡也要求改一個受保護的檔案。四個很少。它提示了四到六倍的差距,但它顯示不出百分之十的差距。
這類任務分兩種。能力任務檢查設定還做不到的事,所以一開始預期常常失敗。回歸任務檢查已經能用的事,所以預期每次都通過,失敗就表示有改動把它弄壞了。有意地把兩種混在一起,並且對兩種用不同的方式讀通過率。
這個倉庫是虛構的(93 個檔案、5 個區域),而且不能執行。這是一個選擇。正確答案事先就知道,所以腳本可以說哪個結果是對的,沒有人需要執行程式碼去查。
看結果,還是看過程?
評分器可以看兩樣東西。
- 結果:agent 留下來的檔案。它加了五個檔案嗎?登記表列出了新的 pipeline 嗎?受保護的檔案沒動嗎?
- 過程:agent 怎麼做到的。它有被拒絕嗎?它有沒有在計畫批准之前就寫到某個地方?
大多數任務,給結果打分。到達正確答案通常有很多有效的路,堅持只走一條路的評分器,會把好的工作判成錯的。只有過程本身就是你在乎的東西時,才給過程打分,例如「規則在計畫批准之前,拒絕寫入」。在我的 harness 裡,這類情境看兩件事:日誌必須顯示拒絕,檔案必須沒有變。這就是 記錄每一次呼叫 要排在最前面的原因。
在我的實驗的評分裡,結果是一張檢查清單。有些項目每個任務都一樣:倉庫仍然一致(檔案有效、每個 pipeline 有它的五個檔案、欄位一致、受保護的區域沒動)。有些項目只屬於一個任務:要求本身做完了。還有一項檢查範圍:只有該改的檔案被改了。一個任務要每一項都通過才算通過。這是全有或全無;如果你想在長任務上看到進度,就分段打分(部分給分),並報告各段。對這些短任務來說,一項錯通常就表示結果是錯的,所以我不拆。
用腳本還是用模型當評分器
腳本讀檔案,回答通過或失敗。模型可以讀結果,給出判斷。各有弱點。
- 腳本便宜、快,每次給同樣的答案。弱點是脆:它可能把有效的結果判成錯的,因為它找的是某一種特定的形式。你要靠讀失敗的結果才找得出來。
- 模型評分器可以接受有效的變化,也能判斷腳本做不到的事,例如一段解釋清不清楚。但它的答案每次運行可能不同,而且可能和被它評分的 agent 有同樣的盲點(模型能檢查模型嗎)。
Anthropic 的建議也一致:「我們建議盡量選確定性的評分器,必要時,或需要額外彈性時,才用 LLM 評分器。」(Demystifying evals for AI agents)答案能在檔案裡檢查的地方,我就用腳本;模型評分器只留給腳本看不到的少數東西。這裡的實驗沒有模型評分器。
先證明評分器是對的
評分器是程式,程式有 bug。什麼都放行的評分器,會讓每個改動看起來都無害。什麼都擋的評分器,會讓每個改動看起來都有害。所以在相信任何分數之前,我先測評分器。我的實驗有一個自我測試,分三部分:
- 沒動過的倉庫,必須每個任務都失敗(什麼都沒做)。
- 手寫的正確答案,必須每個任務都通過。
- 正確答案的壞版本,必須全部被抓到。有 23 個,每個有一個錯誤,例如少了一行登記,或欄位錯了。評分器放過一個,評分器就是錯的。
最小的版本是一個好答案,和一個你手動弄壞的答案:評分器必須放行第一個、抓到第二個。對我的實驗來說,這花了一個下午,而這正是大家會跳過的部分。這也是我能說「一項失敗是有意義的」的原因。
讀失敗的運行
有一個習慣,就算有腳本我也不放棄。一次運行失敗,我會打開它,讀發生了什麼。分數說有東西失敗了。它不說為什麼,而為什麼可能是三種很不一樣的事:
- agent 真的犯了錯。這是評測要找的。
- 評分器錯了。結果是對的,但形式是腳本沒預期的。
- 任務不清楚。兩個答案都講得通,而要求沒有說是哪一個。
只有第一種告訴你 agent 的事。如果你把每個失敗都當成第一種,你會丟掉好的改動、留下壞的。Anthropic 是這麼說的:「讀對話紀錄,是你驗證評測量的是不是真正重要的東西的辦法。」(同一篇文章)
所以腳本不取代看。它取代的是什麼都看、靠猜該看哪裡。腳本挑出失敗的運行。然後由人去讀那些。
你的任務和公開的基準測試
基準測試(benchmark)是一組公開的任務,對每個人用同樣的方式打分,讓模型可以比較。基準測試只對一個問題有用:這個模型在別人的任務上表現如何?它們回答不了另一個問題:我對我的設定做的改動,在我的工作上有沒有幫助?那需要你的倉庫裡的任務,和你的規則,例如我的實驗裡那個受保護的檔案。這就是我自己建的原因。
自己建的代價是:它很小,它是我的,而且會過期。倉庫變了,任務也得跟著變。
我的 harness 今天怎麼做
在我的設定裡有幾個固定情境。每一個是一個 prompt,加上預期的結果:日誌裡必須出現的幾個呼叫(例如一次拒絕),和必須變或不能變的幾個檔案。我在 Copilot 裡手動跑一個情境一次,再由一個檢查讀日誌和檔案,說有沒有做對。寫這段的時候(2026 年 10 月),在我自己的設定裡,我看到 Copilot 的非互動模式不會執行 hook,所以我沒辦法批次跑這些情境,在真實任務上做前後比較也還沒做。我用數字做過的,是這個倉庫裡的實驗。日常使用中,那是手動跑一個情境,再看它留下的日誌。這一章講的有打分、可重複的比較,是那個實驗。
自己跑
這個實驗是 慎用子 agent 裡那些數字背後的測試:虛構的倉庫、四個任務和評分腳本。它適用於任何 agent 工具。labs/subagents/ 說了怎麼先跑自我測試,再跑你自己的比較。看懂怎麼運作之後,把任務換成你自己的。
測你自己的設定
對你即將在 agent 設定上做的任何改動,問三個問題:
- 如果這個改動有幫助,我會看到什麼?如果沒有,又會看到什麼?
- 腳本分得出這兩種嗎?
- 腳本自己有沒有通過「沒動過、正確、壞掉」的測試?
一個不用工具的小開始。挑三個你和 agent 做過的任務。對每一個,寫下你預期最後會有的檔案,和一個你見過的錯誤。寫一個短腳本檢查這些檔案。(如果你的工作不是程式碼,就檢查輸出:表格的欄位、列數、總和。)在一個好結果和一個你手動弄壞的結果上各跑一次。它抓到壞的、放行好的,你就有一個評測了。它很小。下次你改規則時就用它。
原理
方法有四步。图里画出来了;下面各节说怎么把每一步做好。
- 写下一小组固定任务,每个都有已知的正确答案。每次运行之间不变。
- 改动之前和之后,用同样的方式跑同一组任务。
- 脚本读结果,逐项打分,过或不过。每次都是同一个脚本。
- 比较两份成绩单。改动是有帮助、有坏处,还是没差?
- 然后读失败的运行。分数告诉你有东西失败了;读过才知道为什么。
好任务长什么样
不是每个任务都适合做评测。我看三点。
- 它是真的。它该像 agent 平时替你干的活,而不是考试题。如果你只加 pipeline、修公式,就别去测写诗。一个改动只在编出来的活上有用,在你的活上没用,什么也教不了你。
- 它有一个能检查的正确答案。“加一条 pipeline”可以检查:五个文件存在,位置对,彼此一致。“把代码写得更好看”不行。如果两个讲道理的人对结果对不对会有分歧,脚本就没法打分。
- 它覆盖人真正会犯的错。好的一组任务里有简单的,也有陷阱。在我的实验里,有一个任务要 agent 去改一个规则禁止它改的文件。好结果是拒绝。放这个任务,是因为真实的需求就可能这么要求,而听话照做的 agent 就是做错了。
我实验里的四个任务是从小到中等:加一条 pipeline;把一个字段沿三条 pipeline 往下游传(其中一个字段中途改了名);跨领域给一条 pipeline 改名并删掉旧文件;修一个在两处都有的公式,而需求同时要求改一个受保护的文件。四个很少。它能看出四到六倍的差距,看不出一成的差距。
这类任务有两种。能力任务检查配置还做不到的事,所以一开始你预期它常常失败。回归任务检查已经能做的事,所以你预期它每次都通过,一旦失败,就是某个改动把它弄坏了。有意把两种混在一起,并且对两种的通过率要分开解读。
这个仓库是编出来的(93 个文件,5 个领域),也跑不起来。这是有意的选择。正确答案是事先知道的,所以脚本能判断哪个结果对,没人需要运行代码来确认。
看结果,还是看过程?
打分器可以看两样东西。
- 结果:agent 留下的文件。它加了那五个文件吗?注册表里列出了新的 pipeline 吗?受保护的文件没动吗?
- 过程:agent 是怎么做到的。它被拒绝过吗?计划还没审批,它就往某个地方写了吗?
大多数任务,给结果打分。通向正确答案的有效路径通常有很多条,死咬一条路径的打分器,会把好的活判成错的。只有当过程本身就是你在意的东西时,才给过程打分,比如“计划审批之前,规则会拒绝写入”。在我的 harness 里,这类场景看两样:日志里必须有那次拒绝,文件必须没变。有日志才能这么做,这就是为什么要先记录每一次调用。
在我实验的打分里,结果是一张清单。有些项对每个任务都一样:仓库仍然自洽(文件有效、每条 pipeline 都有它的五个文件、字段一致、受保护的区域没动)。有些项只针对一个任务:需求本身做完了。还有一项检查范围:只有该改的文件被改了。只有每一项都通过,任务才算通过。这是全有或全无;如果你想在长任务里看到进展,就分部分打分(给部分分),并分别报告各部分。对这样的短任务,错一项通常就意味着结果是错的,所以我不拆。
用脚本还是用模型打分
脚本读文件,回答通过或不通过。模型可以读结果,给出判断。两者各有弱点。
- 脚本便宜、快,每次答案都一样。它的弱点是脆:它可能因为只认一种特定的写法,而把有效的结果判错。这些问题要靠读失败的运行才能发现。
- 模型打分器能接受有效的变体,也能判断脚本判断不了的东西,比如一段解释清不清楚。但它的答案可能每次运行都不一样,还可能和被它打分的 agent 有同样的盲点(模型能检查模型吗)。
Anthropic 的建议与此一致:“能用确定性的打分器就用,必要时,或者为了更灵活,再用 LLM 打分器。”(Demystifying evals for AI agents)凡是答案能在文件里查出来的,我就用脚本;模型打分器只留给脚本看不到的少数事情。这里的实验没有用模型打分器。
先证明打分器靠谱
打分器是个程序,程序有 bug。什么都放过的打分器,会让每个改动看起来都无害。什么都判失败的打分器,会让每个改动看起来都有害。所以在信任任何分数之前,我先测打分器。我的实验有一个自测,分三部分:
- 没动过的仓库,必须每个任务都不通过(什么都没做)。
- 手写的正确答案,必须每个任务都通过。
- 正确答案的破坏版本,必须全部被抓出来。一共 23 个,每个带一处错误,比如少了一行注册表,或者字段写错了。只要打分器放过一个,打分器就是错的。
最小的版本是一个好答案,加一个你亲手弄坏的答案:打分器必须放过前者,抓住后者。对我的实验,这花了一个下午,而这是人最爱跳过的一步。我能说“失败的一项是有意义的”,也是因为做了这一步。
去读失败的运行
有一个习惯,哪怕有了脚本我也不放弃。一次运行失败了,我就打开它,读发生了什么。分数只告诉你有东西失败了。它不告诉你为什么,而原因可能是三种很不一样的情况:
- agent 真的犯了错。评测就是为这个设的。
- 打分器错了。结果其实是对的,只是形式不是脚本预期的。
- 任务不清楚。有两种答案都说得通,需求没说要哪一种。
只有第一种,才能告诉你 agent 的情况。如果你把每次失败都当成第一种,就会丢掉好的改动、留下坏的改动。Anthropic 是这么说的:“读 transcript,才能确认你的评测衡量的是真正重要的东西。”(同一篇文章)
所以脚本不能取代亲自去看。它取代的是“什么都看一遍,还得猜该看哪些”。脚本挑出失败的运行,再由人去读。
你自己的任务和公开的基准
基准(benchmark)是一组公开的任务,对所有人用同样的方式打分,这样模型之间可以比较。基准只适合回答一个问题:这个模型在别人的任务上表现如何?它回答不了另一个问题:我对自己配置做的改动,在我的活上有没有用?要回答这个,你需要来自你仓库的任务,和你自己的规则,比如我实验里那个受保护的文件。这就是我自己搭一套的原因。
自己搭的代价是:它很小,它是我自己的,而且会过期。仓库变了,任务也得跟着变。
我的 harness 现在做到哪一步
在我的配置里,有几个固定的场景。每个场景是一个 prompt 加上预期结果:日志里必须出现的几次调用(比如一次拒绝),和必须改或不能改的几个文件。我在 Copilot 里手动跑一次场景,再由一个检查读日志和文件,告诉我做得对不对。写作时(2026 年 10 月),我在自己的配置里看到,Copilot 的非交互模式不运行 hook,所以我没法批量跑这些场景,在真实任务上做改动前后的对比也还没做。我用数字做过的,是这个仓库里的实验。日常使用中,就是手动跑一个场景,再看它留下的日志。本章讲的这种带打分、可重复的对比,是实验里才有的。
自己跑一遍
这个实验是慎用子 agent里那些数字背后的测试:编出来的仓库、四个任务和打分脚本。它适用于任何 agent 工具。labs/subagents/讲了怎么先跑自测,再跑你自己的对比。看明白怎么用之后,把任务换成你自己的任务。
测你自己的配置
对 agent 配置要做的任何改动,问三个问题:
- 如果这个改动有用,我会看到什么?如果没用,又会看到什么?
- 脚本能把这两种情况区分开吗?
- 脚本本身通过了“没动过的、正确的、被弄坏的”这三项测试吗?
不用任何工具的小起步。挑三个你用 agent 做过的任务。对每一个,写下你预期最后会有的文件,和一个你见过的错误。写一个短脚本检查这些文件。(如果你的工作不是代码,就检查输出:表的列、行数、合计。)用它跑一个好结果,再跑一个你手动弄坏的结果。如果它抓住了坏的、放过了好的,你就有了一个评测。它很小。下次改规则的时候就用它。
Costs and traps
Four tasks are a thin base. They can show a large gap. They cannot show a small one, and they do not cover what you did not think of. Add a task each time a real failure surprises you.
You can fit the setup to the test. If you change the setup until the tasks pass, you have measured how well you fit those four tasks. Keep some tasks aside that you do not tune against.
A static score does not run the code. My grader reads files. It cannot say that the code works. For work where running matters, the grader has to run the tests (Let the agent check its own work).
Tasks saturate. Anthropic's word is "Eval saturation occurs when an agent passes all of the solvable tasks, leaving no room for improvement." When every setup passes every task, the eval can no longer tell them apart. Add harder tasks.
Tasks must not share state. Start every run from the same clean copy. If one run leaves files, caches or a changed setting behind, the next run is not a fair test, and the score measures the leftovers.
Running costs money and time. In my lab, the team took about 16 minutes and about 456 AI credits for four tasks, once. Prompt caching changes the sum: on Anthropic's API a cached read costs about a tenth of the base price (Models and cost), but I have not checked how Copilot bills it. A set of ten tasks, run several times on two setups, is a real bill. Decide before you start what you will do with the answer. And in my setup the non-interactive mode of Copilot does not run hooks, so real work cannot be run in a batch for this (see "What my harness does today").
One run is thin. My results are one run per task. The next chapter says how to run more and how to report what you find.
代價和陷阱
四個任務是很薄的基礎。它們能顯示大的差距。顯示不出小的,也涵蓋不了你沒想到的。每次有真實的失敗讓你意外,就加一個任務。
你可能把設定調成配合測試。如果你一直改設定,直到任務通過,你量到的是你配合這四個任務配合得多好。留一些不拿來調的任務。
靜態的分數不執行程式碼。我的評分器讀檔案。它沒辦法說程式碼能不能用。對執行很重要的工作,評分器得去跑測試(讓 agent 能檢查自己的活)。
任務會飽和。Anthropic 的說法是「當 agent 通過所有可解的任務,沒有留下任何進步空間,就是評測飽和。」當每種設定都通過每個任務,評測就再也分不出它們。加更難的任務。
任務之間不能共用狀態。每次運行都從同一份乾淨的副本開始。如果一次運行留下了檔案、快取或改過的設定,下一次運行就不是公平的測試,分數量到的是殘留的東西。
運行要花錢和時間。在我的實驗裡,團隊做四個任務,一次大約 16 分鐘、大約 456 個 AI credits。prompt 快取會改變總額:在 Anthropic 的 API 上,快取讀取大約是基本價格的十分之一(選模型:算的是每次成功的成本),但 Copilot 怎麼計費,我沒查過。十個任務,在兩種設定上各跑幾次,是一筆真的帳單。開始之前先決定,你拿到答案要做什麼。而且在我的設定裡,Copilot 的非互動模式不會執行 hook,所以真實的工作沒辦法為此批次跑(見「我的 harness 今天怎麼做」)。
一次運行很薄。我的結果是每個任務一次運行。下一章 說怎麼跑更多次、怎麼報告你發現的東西。
代价和坑
四个任务的底子很薄。它们能显示大的差距。显示不了小的差距,也覆盖不了你没想到的东西。每次遇到出乎意料的真实失败,就加一个任务。
你可能把配置调得只适合这个测试。如果你不停改配置直到任务通过,你量到的是它对这四个任务拟合得有多好。留一些你不拿来调优的任务。
静态打分不运行代码。我的打分器读文件。它没法说代码能不能跑。对运行结果要紧的活,打分器得去跑测试(让 agent 能检查自己的活)。
任务会饱和。Anthropic 的说法是:“评测饱和,是指 agent 通过了所有可解的任务,再没有改进的余地。”当每种配置都通过每个任务,评测就不再能区分它们。加更难的任务。
任务之间不能共享状态。每次运行都从同一份干净的副本开始。如果某次运行留下了文件、缓存或改过的设置,下一次运行就不是公平的测试,分数量到的是残留物。
运行要花钱和时间。在我的实验里,团队做完四个任务,一次约 16 分钟、约 456 AI credits。prompt 缓存会改变这笔账:在 Anthropic 的 API 上,命中缓存的读取约是基础价格的十分之一(选模型:看每次成功的成本),但我没有查过 Copilot 怎么计费。十个任务,在两种配置上各跑好几次,是一笔实在的账单。动手之前先想好,答案出来后你打算拿它做什么。另外,在我的配置里,Copilot 的非交互模式不运行 hook,所以真实的工作没法为此批量运行(见“我的 harness 现在做到哪一步”)。
一次运行很单薄。我的结果是每个任务跑一次。下一章讲怎么多跑几次,以及怎么汇报你发现的东西。
When to delete it Industry practice
The scripts and the habit of running by hand exist because I have no built-in way to run a setup through a fixed set of tasks and compare. If a platform adds that, with logs and scoring, I would use it and drop my glue.
The fixed tasks do not retire. A model is upgraded, a rule is added, a prompt is rewritten: each is a change, and each needs the same answer to the same question (When the model is upgraded). A task retires when every setup passes it. I would look again at the lab's four tasks if they stopped telling the setups apart.
什麼時候可以刪掉 業界做法
這些腳本和手動跑的習慣存在,是因為我沒有內建的辦法,讓一種設定跑一組固定任務並比較。如果平台加了這個功能,有日誌也有打分,我會用它,把我自己黏起來的東西丟掉。
固定任務不會退役。模型升級了、加了一條規則、重寫了一個 prompt:每一個都是改動,每一個都需要對同一個問題給同一種答案(模型升級了,就要刪)。一個任務在每種設定都通過它的時候退役。如果實驗裡的四個任務不再分得出各種設定,我會重新檢視它們。
什么时候可以删掉 业界做法
这些脚本和手动运行的习惯之所以存在,是因为我没有内置的办法,把一套配置放到一组固定任务上跑一遍再比较。如果哪个平台加了这个功能,带日志和打分,我会用它,把自己的胶水代码丢掉。
固定任务不会退休。模型升级了,加了一条规则,重写了一个 prompt:每一个都是改动,每一个都需要对同一个问题给出同样的答案(模型升级了,就要删)。一个任务只有在每种配置都能通过时才退休。如果实验里这四个任务不再能区分各种配置,我会重新审视它们。
Try it on your own setup
No harness needed. Open your agent in your own repository and paste:
Look at the last ten commits that changed instruction, skill, agent or hook files in this repository. For each, say what evidence (if any) was given that the change helped. Then propose three fixed tasks taken from this repository's real history: for each, the request, the starting commit, and an end state that a script could check from the files alone. Include one task where the right result is a refusal. Do not create or change any files.在你自己的環境試試
不用裝 harness。在你自己的倉庫裡打開 agent,貼上:
看這個倉庫裡最近十個改過指令、skill、agent 或 hook 檔案的 commit。對每一個,說明有沒有(如果有,是什麼)證據顯示這個改動有幫助。然後從這個倉庫的真實歷史,提出三個固定任務:每個任務寫出要求、起始的 commit,以及一個腳本只靠檔案就能檢查的結束狀態。其中包含一個正確結果是拒絕的任務。不要建立或改任何檔案。在你自己的环境里试试
不需要 harness。在你自己的仓库里打开 agent,粘贴:
看这个仓库里最近十次改过指令、skill、agent 或 hook 文件的提交。对每一次,说明当时有没有给出证据(如果有)证明这个改动有用。然后从这个仓库的真实历史里,提出三个固定任务:每个给出需求、起始提交,以及一个脚本只看文件就能检查的结束状态。其中包含一个正确结果是拒绝的任务。不要创建或修改任何文件。Go deeper
- Anthropic: Demystifying evals for AI agents
- In this repository:
labs/subagents/, with the scorer and its self-test - In this book: Record what happened, not what the agent said, One run proves nothing
延伸閱讀
- Anthropic:Demystifying evals for AI agents
- 本倉庫:
labs/subagents/,有評分腳本和它的自我測試 - 本書:記下發生了什麼,不是 agent 說了什麼、一次運行證明不了什麼
延伸阅读
- Anthropic:Demystifying evals for AI agents
- 本仓库内:
labs/subagents/,含打分脚本和它的自测 - 本书内:记下发生了什么,而不是 agent 说了什么、一次运行证明不了什么
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
Copilot Harness has a few fixed scenarios that are judged from the log and from the files left behind. The harness can show you how one is written and how it is checked. After the setup above, type:
/harness-rookie-wondering I have read the chapter "Fixed tasks, scored by a script". Teach me how this harness's fixed scenarios work (topic 12): what a scenario holds, how a check reads the log and the files, and what the scenarios cannot do yet. Open one real scenario 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 有幾個固定情境,由日誌和留下來的檔案來判斷。harness 可以給你看一個情境怎麼寫、怎麼檢查。照上面的說明準備好之後,輸入:
/harness-rookie-wondering 我讀完了「固定的任務,用腳本打分」這一章。請教我這個 harness 的固定情境怎麼運作(主題 12):一個情境放什麼、檢查怎麼讀日誌和檔案、這些情境還做不到什麼。帶我打開一個真的情境,並畫出這些部分怎麼接在一起。它一次教一小塊,停下來確認你跟得上,然後和你一起打開檔案。
在 harness 里探索
Copilot Harness 有几个固定场景,根据日志和留下的文件来判断。harness 能给你看一个场景怎么写、怎么检查。完成上面的配置后,输入:
/harness-rookie-wondering 我读过“固定的任务,用脚本打分”这一章。请教我这个 harness 的固定场景怎么工作(主题 12):一个场景里有什么,检查怎么读日志和文件,场景现在还做不到什么。和我一起打开一个真实的场景,画出各部分是怎么配合的。它一次只教一小块,会停下来问你跟不跟得上,并和你一起打开文件。