> Harness EngineeringHarness EngineeringHarness Engineering The engineering outside the model模型之外的工程模型之外的工程

5.3

Two gates: where a person approves兩道門:人在哪裡批准两道门:人在哪里审批

This chapter assumes you have read Ask or refuse and Guardrails: why "ask me first" is not a limit, and why the agent must not be able to edit the rules.

讀這一章,你需要讀過 詢問不是限制 和 保護規則本身的檔案:為什麼「先問我」不是限制,以及為什麼 agent 不能改規則。

读这一章之前,你要读过询问不是限制和保护规则本身的文件:为什么“先问我”不是限制,以及为什么 agent 不能有权编辑规则。

The Knowledge經驗分享经验分享

In one sentence

Put a person at the points that cost money, grant power or cannot be undone. Make the approval come through a channel the agent cannot reach, and bind it to exactly the plan that was approved.

一句話

在花錢、給權力、不能反悔的地方放一個人。讓批准從 agent 碰不到的管道進來,而且只綁定到被批准的那一份計畫。

一句话

在花钱、授权、无法撤销的地方放一个人。让审批走 agent 够不着的渠道,并把它绑定到被批准的那份计划上,一字不差。

For leaders

  • The decision: decide where a person must approve: at points that cost money, grant power or cannot be undone, and nowhere else. The approval must come through a channel the agent cannot reach, and it must belong to exactly the plan or change the person read.
  • The risk: a confirmation box can be switched off for the session without anyone noticing, and an approval the agent can give itself is not an approval. A tired person can still approve without reading; binding the approval to the content stops a swap, not a careless yes.
  • The cost of doing it right: each gate costs a person one read and one command. Too many gates and people stop reading. In my setup, snapshots at the gates are kept for 14 days by default.
  • Ask the team: "Which approvals in our flow could the agent give itself or switch off, and does an approval still count if the plan changes afterwards?"

給主管

  • 要做的決定:決定人必須在哪裡批准:花錢、給權力、不能反悔的地方,其他地方都不用。批准必須走 agent 碰不到的管道,而且只屬於人讀過的那份計畫或那次改動。
  • 風險:確認框可以在整個會話裡被悄悄關掉,而 agent 能自己給的批准不是批准。累了的人還是可能不讀就批准;把批准綁到內容上,擋得住掉包,擋不住隨手按的「好」。
  • 做對的成本:每道門要人讀一次、打一個指令。門太多,人就不讀了。在我的設定裡,門上的快照預設保留 14 天。
  • 可以問團隊:「我們的流程裡,哪些批准是 agent 能自己給或自己關掉的?計畫事後改了,批准還算數嗎?」

写给管理者

  • 要拍板的事:决定哪些地方必须由人审批:花钱、授权、无法撤销的地方,别的地方都不用。审批必须走 agent 够不着的渠道,并且只属于人读过的那份计划或改动。
  • 风险:确认框可以在整个会话里被关掉,而没有人注意到;agent 自己能给的审批,不是审批。疲惫的人仍然可能不读就批;把审批绑定到内容上,能防住被调包,防不住草率地点“同意”。
  • 做对的代价:每道关卡让人读一次、敲一条命令。关卡太多,人就不读了。在我的配置里,关卡处的快照默认保留 14 天。
  • 可以问团队:“我们的流程里,哪些审批是 agent 能自己给、或者能关掉的?计划事后改了,审批还算数吗?”

The problem

You want a person to approve the important steps. The obvious tool is the confirmation box that the agent tool shows: "Allow this?" It does not work well, for two reasons.

First, people click Allow. By the hundredth box they are not reading it (Ask or refuse). Second, many tools let you tick "allow for this session", and then the box never appears again. The approval you relied on is gone, and nothing tells you.

A third problem is subtler. Suppose the approval is a command the person types. If the agent can run commands, it can type that command too. An approval that the agent can give is not an approval.

So the question is where to put the person, and how to make their yes something the agent cannot produce or reuse.

問題

你想讓人批准重要的步驟。最直接的工具是 agent 工具跳出的確認框:「允許這個嗎?」它效果不好,原因有兩個。

第一,人會按允許。到第一百個框,就沒人在讀了(詢問不是限制)。第二,很多工具讓你勾「這個會話都允許」,之後框就再也不出現。你倚靠的批准不見了,也沒有任何東西告訴你。

第三個問題更微妙。假設批准是一個由人打出來的指令。如果 agent 能執行指令,它也能打出同一個指令。agent 自己能給的批准,不是批准。

所以問題是:人要放在哪裡,以及怎麼讓他的「好」成為 agent 造不出來、也沒辦法重複使用的東西。

问题

你想让人批准重要的步骤。最顺手的工具,是 agent 工具弹出的确认框:“允许吗?”它不太管用,有两个原因。

第一,人会点“允许”。到第一百个框的时候,他们已经不读了(见询问不是限制)。第二,很多工具让你勾选“本次会话都允许”,勾了之后框就再也不出现了。你依赖的审批没了,也没有任何东西告诉你。

第三个问题更微妙。假设审批是人敲的一条命令。如果 agent 能运行命令,它也能敲这条命令。agent 能自己给的审批,不是审批。

所以问题是:把人放在哪里,以及怎样让他的“同意”成为 agent 造不出来、也重复用不了的东西。

How it works

Where to put the person

A person's attention is the scarcest thing in the system. Spend it on three kinds of point, and nowhere else:

  • Points that cost money. For example, starting an expensive run.
  • Points that grant power. Letting the agent write to a shared repository.
  • Points that cannot be undone. Something that cannot be taken back once done.

Everything inside a task folder is cheap to redo, so the agent works there freely (Manage tasks, not chats). A task that changes a real repository has two such points. I call each a gate: the task cannot pass until a person approves.

plan written, then stop gate 1 you, in a terminal approve the plan work inside the folder snapshots at the gates gate 2 you, in a terminal approve the diff repo a new branch plan changed: the approval no longer holds
  1. The agent writes the plan and stops. It cannot go on.
  2. Gate 1. The person reads the plan in an editor, then types the approval in a terminal. The agent has no way to type it.
  3. The agent works inside the task folder. A copy of the work is kept at each gate, so a broken state can be found again.
  4. Gate 2. The person reads the exact diff, then approves in the terminal. Only then does the result reach the repository.
  5. The approval is tied to the exact plan that was read. Change the plan and the approval is void.
Two gates, at the points that cost money, grant power or cannot be undone. Each is an action the agent cannot do for the person.

Gate 1: approve the plan

The agent writes the requirement and a plan, then stops. The person reads the plan, and only then approves. Before this, the agent may draft and read; it may not start changing the work files.

The point of this gate is cost. A wrong plan is cheap to fix as a paragraph and expensive to fix as a finished change. In my setup the plan also stands on a confirmed requirement (The agent writes the requirement), so one approval can confirm both.

Gate 2: approve the write-back

The agent has made the changes in the task folder, and checks have run. Now the result is about to go to the real repository. Copying it there is the write-back. The person reads the exact diff: the list of lines that would change. Then they approve.

At the write-back, the result goes to a new branch of the repository and is left uncommitted. It never touches the main branch directly. And before it is written, code checks that:

  • the working tree is clean,
  • the branch name is free,
  • none of the files to change has moved on the main branch since it was copied.

If any repository fails a check, nothing is written. This is also where two people, or two tasks, changing the same file are found: by the program here, not later in a review.

Why the approval is typed in a terminal

A confirmation box in the chat can be switched off by "allow for this session". A code that the person types in a terminal cannot. The approval command needs a real terminal, and when an agent runs it, it is refused. Three points make this hold:

  1. The terminal is not a wall. A check that "this is a terminal" is not a security boundary; a determined program can imitate one.
  2. A hook is the second leg. It is code that refuses the agent's attempt to run the approval command at all, and it sits outside the agent's reach, as Guardrails explains. If that hook is gone, or the agent can edit it, the approval is only a polite request. The design stands on both legs, and neither is enough alone.
  3. The refusal must survive an error. The enforcement layer lets a call through when it breaks itself (Build the enforcement layer like software). So the refusal of the approval command belongs on the short list of rules that must block even when the hook errors; otherwise this leg breaks exactly when it is needed.

The content is read elsewhere. Plans and diffs are hard to read in a terminal, so the person reads them in an editor, and the terminal shows only the file path and the code to type. Reading and approving are separate acts on purpose.

Tie the approval to what was read

Suppose the person approves a plan, and then the agent edits the plan. Is the approval still good? It should not be. So the code the person types is derived from the plan's content: a hash, a fingerprint that changes if one character changes. When the plan changes after approval, the approval no longer matches, and the gate closes again.

The same goes for the write-back: the approval belongs to the exact diff that was shown. This is what "bind it to exactly the plan that was approved" means. Without it, a person approves one thing and the agent delivers another.

Snapshots at the gates

When the plan is approved, before each check, and before the dry run of a write-back, a copy of the work (a snapshot) is saved automatically. When something breaks, the state of that moment can be found again. In my setup they are kept for 14 days by default.

A failure in the middle of a write to several repositories is not rolled back by itself. The task goes to a "partly written" state, and a person runs a recovery. I chose not to guess at an automatic undo.

Without any of this machinery

The habit works by hand too. Read the plan before you tell the agent to go. Read the diff before you commit. Do not tick "allow for this session" on a tool that writes. The machinery above only makes sure these happen when you are tired or not there.

Several rounds

After a write-back, the same goal can come back: a reviewer finds a defect, or a change is asked for. A new round starts. The old work moves aside, a new plan is written, and both gates apply again. A different goal is a new task.

Testing in other environments is not another round. The agent cannot run anything there; the person does. That becomes its own task of kind testing, where the agent writes the instructions, waits for the person's results, and judges them. A failed test goes back to the development task as a new round.

原理

人要放在哪裡

人的注意力是系統裡最稀少的東西。只把它花在三種地方,其他地方都不花:

  • 花錢的地方。例如,開始一次昂貴的運行。
  • 給權力的地方。讓 agent 寫入共用的倉庫。
  • 不能反悔的地方。做了就收不回來的事。

任務資料夾裡的一切,重做都很便宜,所以 agent 在那裡可以自由工作(管任務,不管對話)。一個會改動真實倉庫的任務有兩個這樣的地方。我把每一個叫做門:人批准之前,任務不能通過。

計畫 寫完就停 第一道門 你,在終端機 批准計畫 工作 在資料夾裡 過門時留快照 第二道門 你,在終端機 批准差異 倉庫 寫進新分支 計畫改了:批准就不再有效
  1. agent 寫好計畫就停下,不能繼續。
  2. 第一道門。人在編輯器裡讀計畫,再到終端機輸入批准。agent 沒辦法替人輸入。
  3. agent 在任務資料夾裡工作。每道門都留一份工作的副本,壞了可以找回那一刻的樣子。
  4. 第二道門。人讀確切的差異,再在終端機批准。之後結果才進到倉庫。
  5. 批准綁在人讀過的那份計畫上。計畫一改,批准就作廢。
兩道門,放在花錢、放權、不可逆的點上。每道都是 agent 替不了人做的動作。

第一道門:批准計畫

agent 寫出需求和計畫,然後停下來。人讀計畫,讀完才批准。在這之前,agent 可以起草、可以讀;不能開始改工作檔案。

這道門是為了成本。計畫錯了,改一段文字很便宜;錯到做完才改,就很貴。在我的設定裡,計畫也建立在已確認的需求上(需求由 agent 寫,人確認),所以一次批准可以同時確認兩者。

第二道門:批准寫回

agent 已經在任務資料夾裡做完改動,檢查也跑過了。現在結果要送到真實的倉庫。把它複製過去叫寫回。人讀的是確切的 diff:會被改動的那些行的清單。然後批准。

寫回時,結果會進到倉庫的一個新分支,而且不提交。它絕不會直接碰主分支。寫入之前,程式先檢查:

  • 工作樹是乾淨的,
  • 分支名稱沒被用掉,
  • 要改的檔案,自從被複製之後,在主分支上都沒有動過。

只要有一個倉庫沒通過檢查,就什麼都不寫。兩個人、或兩個任務改同一個檔案,也是在這裡被發現的:由程式在這裡發現,不是之後在審查裡。

為什麼批准要在終端機裡打

聊天裡的確認框,可以被「這個會話都允許」關掉。人在終端機裡打的一段碼,不行。批准指令需要真正的終端機,agent 去執行它時會被拒絕。有三點讓這件事成立:

  1. 終端機不是牆。檢查「這是終端機」不是安全邊界;有心的程式可以假裝。
  2. hook 是第二條腿。它是一段程式碼,直接拒絕 agent 去執行批准指令,而且它在 agent 碰不到的地方,像 保護規則本身的檔案 說的。如果這個 hook 不見了,或 agent 能編輯它,批准就只是客氣的請求。這個設計站在兩條腿上,單靠任何一條都不夠。
  3. 拒絕必須撐過錯誤。執行層在自己壞掉時會放行呼叫(把執行層當軟體來設計)。所以拒絕批准指令,要放在那份「即使 hook 出錯也必須擋住」的短清單上;不然這條腿剛好在最需要的時候斷掉。

內容在別處讀。計畫和 diff 在終端機裡很難讀,所以人在編輯器裡讀,終端機只顯示檔案路徑和要打的碼。讀和批准是兩個動作,這是故意的。

把批准綁到讀過的內容

假設人批准了一份計畫,然後 agent 改了這份計畫。批准還有效嗎?不應該。所以人要打的碼,是從計畫的內容算出來的:一個 hash,一種指紋,改一個字就會變。批准之後計畫變了,批准就對不上,門就又關上了。

寫回也一樣:批准屬於當時顯示的那份確切的 diff。「綁定到被批准的那一份計畫」就是這個意思。沒有這一步,人批准的是一樣東西,agent 交出的卻是另一樣。

門上的快照

計畫被批准時、每次檢查之前、寫回的試跑之前,都會自動存一份工作的副本(快照)。哪裡壞了,那個時刻的狀態找得回來。在我的設定裡,預設保留 14 天。

寫入多個倉庫的途中失敗,不會自動回復。任務進入「寫了一部分」的狀態,由人執行恢復。我選擇不去猜一個自動的還原。

沒有這些機制

用手也能養成這個習慣。叫 agent 動手之前,先讀計畫。提交之前,先讀 diff。對會寫入的工具,不要勾「這個會話都允許」。上面的機制,只是確保你累了、或不在的時候,這些事也會發生。

多輪

寫回之後,同一個目標可能再回來:reviewer 找到缺陷,或有人要求改動。新的一輪開始。舊的工作移到一旁,寫新的計畫,兩道門都再走一次。不同的目標是新任務。

在其他環境測試,不算另一輪。agent 在那裡什麼都不能執行,要由人來。那會成為自己的一個測試類任務:agent 寫說明,等人給結果,再判斷結果。測試失敗,就回到開發任務,成為新的一輪。

原理

把人放在哪里

人的注意力是系统里最稀缺的东西。只把它花在三类点上,别的地方不花:

  • 花钱的点。比如启动一次昂贵的运行。
  • 授权的点。让 agent 往共享仓库里写。
  • 无法撤销的点。一旦做了就收不回来的事。

任务文件夹里的一切,重做起来都很便宜,所以 agent 在那里可以随便干(见管任务,不管对话)。改真实仓库的任务有两个这样的点。我把每一个叫一道关卡:人批准之前,任务过不去。

计划 写完就停 关卡 1 你,在终端里 批准计划 工作 在文件夹里 过关时留快照 关卡 2 你,在终端里 批准 diff 仓库 写进新分支 计划改了:批准就不再有效
  1. agent 写好计划就停下,不能继续。
  2. 关卡 1。人在编辑器里读计划,再到终端里敲批准。agent 没办法替人敲。
  3. agent 在任务文件夹里工作。每道关卡都留一份工作的副本,坏了可以找回那一刻的样子。
  4. 关卡 2。人读确切的 diff,再在终端里批准。之后结果才进到仓库。
  5. 批准绑在人读过的那份计划上。计划一改,批准就作废。
两道关卡,放在花钱、授权、无法撤销的点上。每道都是 agent 替不了人做的动作。

关卡 1:批准计划

agent 写出需求和计划,然后停下。人读计划,之后才批准。在此之前,agent 可以起草、可以读;不能开始改工作文件。

这道关卡的意义在成本。一份错的计划,作为一段文字改起来很便宜,作为一个做完的改动改起来很贵。在我的配置里,计划还建立在已确认的需求之上(见需求由 agent 写,人确认),所以一次审批可以同时确认两者。

关卡 2:批准写回

agent 已经在任务文件夹里做完了改动,检查也跑过了。现在结果要进入真实的仓库。把它复制过去,就是写回。人读确切的 diff:将要改动的那些行的清单。然后批准。

写回时,结果进入仓库的一个新分支,并且不提交。它从不直接碰主分支。而且在写之前,代码会检查:

  • 工作树是干净的,
  • 分支名没被占用,
  • 要改的文件在复制之后,没有在主分支上变动过。

只要有一个仓库没通过检查,就什么都不写。两个人、或者两个任务改同一个文件,也是在这里发现的:由这里的程序发现,而不是以后在评审里。

为什么审批要在终端里敲

聊天里的确认框,可以被“本次会话都允许”关掉。人在终端里敲的一个码,关不掉。审批命令需要一个真正的终端,agent 来运行它,就会被拒绝。有三点让这一条站得住:

  1. 终端不是一堵墙。检查“这是个终端”不是安全边界;有心的程序可以假冒。
  2. hook 是第二条腿。它是一段代码,会拒绝 agent 运行审批命令的任何尝试,而且它在 agent 够不着的地方,正如保护规则本身的文件所讲。如果这个 hook 没了,或者 agent 能编辑它,审批就只是一个客客气气的请求。这个设计靠两条腿站着,单靠哪一条都不够。
  3. 拒绝必须经得起出错。执行层在自己出故障时会放行调用(见把执行层当软件来设计)。所以对审批命令的拒绝,应该放在那份即使 hook 出错也必须拦下的短清单上;否则这条腿恰好在最需要它的时候断了。

内容在别处读。计划和 diff 在终端里不好读,所以人在编辑器里读,终端只显示文件路径和要敲的码。读和批准是有意分开的两个动作。

把审批绑在读过的内容上

假设人批准了一份计划,然后 agent 编辑了这份计划。批准还有效吗?不应该有效。所以人要敲的那个码,是从计划的内容算出来的:一个哈希,一个指纹,改一个字符它就变。批准之后计划变了,批准就对不上了,关卡重新关上。

写回也一样:批准属于展示过的那份确切的 diff。这就是“绑定到被批准的那份计划上,一字不差”的意思。没有它,人批准的是一样东西,agent 交付的是另一样。

关卡处的快照

计划被批准时、每次检查之前、写回试运行(dry run)之前,会自动保存一份工作的副本(快照)。出了问题,那一刻的状态能找回来。在我的配置里,它们默认保留 14 天。

往多个仓库写的中途失败,不会自动回滚。任务进入“部分写入”状态,由人来做恢复。我选择不去猜一个自动撤销。

没有这套机制也行

这个习惯用手工也行。叫 agent 动手之前,先读计划。提交之前,先读 diff。对会写东西的工具,别勾“本次会话都允许”。上面的机制只是保证,在你累了或者不在的时候,这些事也照样发生。

好几轮

写回之后,同一个目标可能再来:reviewer 发现了缺陷,或者有人要求改动。新的一轮开始。旧的工作挪到一边,写新的计划,两道关卡再走一遍。不同的目标,是一个新任务。

在其他环境里测试,不算另一轮。agent 在那里运行不了任何东西;由人来跑。这成为一个单独的任务,类型是测试:agent 写说明,等人给结果,再判断结果。测试失败,作为新的一轮回到开发任务。

Costs and traps

  • It stops the agent, and so it slows the work. Each gate costs a person a read and a command. That is the price. If you put gates everywhere, people stop reading, and you are back at the hundredth box.
  • It holds only while the refusing hook is there. If the hook that refuses the approval command is removed, edited or fails, an agent that can run commands could approve for itself. Protect that hook as the rules in Guardrails say, and test it. A test is cheap: ask the agent to run the approval and check that it is refused.
  • A person can approve without reading. Binding the approval to the plan stops a swap. It does not stop a tired yes. Making the diff short and the gates few helps; nothing here removes the problem. One idea I have not tried is to record how long each approval took and how big the diff was: a very fast yes on a big diff is a signal worth looking at.
  • The terminal check is not a lock. Treat it as a guard against accidents, not against an attack (Least privilege).
  • No automatic undo across repositories. A partial failure needs a person.

代價和陷阱

  • 它會讓 agent 停下來,所以工作變慢。每道門要人讀一次、打一個指令。這是代價。門放得到處都是,人就不讀了,又回到第一百個框。
  • 只有拒絕的 hook 在的時候才成立。拒絕批准指令的 hook 如果被移除、被編輯或失敗,能執行指令的 agent 就可能自己批准。照 保護規則本身的檔案 的規則保護這個 hook,並且測試它。測試很便宜:叫 agent 去執行批准,確認它被拒絕。
  • 人可能不讀就批准。把批准綁到計畫,擋得住掉包,擋不住累了的「好」。讓 diff 短、門少,會有幫助;這裡沒有任何東西能消除這個問題。一個我還沒試過的想法,是記下每次批准花了多久、diff 有多大:大 diff 卻很快就批准,是值得看一眼的訊號。
  • 終端機檢查不是鎖。把它當成防意外的措施,不是防攻擊的(有些東西根本不給)。
  • 跨倉庫沒有自動還原。部分失敗需要人處理。

代价和坑

  • 它会拦住 agent,所以会拖慢工作。每道关卡让人读一次、敲一条命令。这就是价钱。如果到处设关卡,人就不读了,你又回到了第一百个框。
  • 只有拒绝用的 hook 在,它才成立。如果拒绝审批命令的 hook 被删了、被改了或者出故障了,能运行命令的 agent 就可能自己批准自己。按保护规则本身的文件里的规则保护这个 hook,并测试它。测试很便宜:让 agent 运行审批,检查它被拒绝。
  • 人可以不读就批。把审批绑到计划上,能防住被调包,防不住疲惫的“同意”。让 diff 短一点、关卡少一点有帮助;这里没有任何东西能消除这个问题。有一个我没试过的想法:记录每次审批用了多久、diff 有多大:对一个大 diff 飞快地批,是值得留意的信号。
  • 终端检查不是锁。把它当作防意外的守卫,不是防攻击的(见有些东西根本不给)。
  • 跨仓库没有自动撤销。部分失败需要人来处理。

When to delete it

The typed-approval mechanism exists because a platform's own confirmation can be switched off for a session, and cannot be tied to a plan's hash. If a platform offers an approval that the agent cannot dismiss, that records what was shown, and that stops being valid when the content changes, use that and drop mine.

The idea stays: a person at the three kinds of point, and an approval that belongs to exactly what they read.

什麼時候可以刪掉

打出來的批准機制存在,是因為平台自己的確認可以在一個會話裡被關掉,也沒辦法綁到計畫的 hash。如果平台提供一種批准:agent 無法關掉、會記錄當時顯示的內容、內容一變就失效,那就用它,把我的拿掉。

想法會留下:在三種地方放一個人,而且批准只屬於他讀過的內容。

什么时候可以删掉

敲码审批的机制之所以存在,是因为平台自己的确认可以在一个会话里被关掉,也没法绑到计划的哈希上。如果平台提供这样的审批:agent 关不掉、会记录展示过什么、内容一变就失效,那就用它,把我的去掉。

想法留着:在三类点上放一个人,审批只属于他读过的那份确切内容。

Try it on your own setup

No harness needed. Open your agent in your own repository and paste:

Walk through how work moves from this agent's changes to the main branch or to production in this project: pull requests, required reviews, CI, deploy steps, and any approval prompts in the agent tools. For each point where money is spent, power is granted or something cannot be undone, say who approves, through what channel, and whether the agent could give or skip that approval. Also say whether the approval would still stand if the change were edited after it was given. Do not change any files.

在你自己的環境試試

不用裝 harness。在你自己的倉庫裡打開 agent,貼上:

走一遍在這個專案裡,工作怎麼從這個 agent 的改動走到主分支或正式環境:pull request、必要的審查、CI、部署步驟,以及 agent 工具裡的任何批准提示。對每一個花錢、給權力或不能反悔的點,說明誰批准、走什麼管道,以及 agent 能不能自己給出或跳過那個批准。也說明:批准給出之後,如果改動又被編輯,批准還算不算數。不要改任何檔案。

在你自己的环境里试试

不用装 harness。在你自己的仓库里打开 agent,粘贴:

梳理一下,在这个项目里,工作是怎么从这个 agent 的改动走到主分支或生产环境的:pull request、必需的评审、CI、部署步骤,以及 agent 工具里的各种审批提示。对每一个花钱、授权或无法撤销的点,说清楚由谁批准、走什么渠道、agent 能不能自己给出或跳过这个审批。另外说一下:如果审批给出之后改动又被编辑了,这个审批还算不算数。不要修改任何文件。

Go deeper

  • Guardrails: why the hook and its files must be out of the agent's reach.
  • Ask or refuse: why a confirmation box is not a limit.
  • Counted checks: the checks that run before the second gate.
  • VS Code docs: Hooks, which say hooks and instructions are not substitutes for enforced permissions.

延伸閱讀

延伸阅读

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

The two gates, the typed approval, the plan hash, and the snapshots run in Copilot Harness. After the setup above, type:

/harness-rookie-wondering I have read the chapter "Two gates". Teach me how this harness builds the two approvals (topic 9, and topic 8 on permissions): why they are typed in a terminal, what the approval is bound to, and which hook refuses the agent. Walk me through a real task going through both gates, and draw it.

It teaches one small piece at a time, stops to ask if you are following, and opens the files with you.

在 harness 裡探索

兩道門、打出來的批准、計畫的 hash 和快照,都在 Copilot Harness 裡執行。照上面的說明準備好之後,輸入:

/harness-rookie-wondering 我讀完了「兩道門:人在哪裡批准」這一章。請教我這個 harness 怎麼做這兩道批准(主題 9,以及講權限的主題 8):為什麼要在終端機裡打、批准綁定到什麼,以及哪個 hook 拒絕 agent。帶我看一個真實的任務怎麼走過兩道門,並且畫出來。

它一次教一小塊,停下來確認你跟得上,然後和你一起打開檔案。

在 harness 里探索

两道关卡、敲码审批、计划的哈希和快照,都在 Copilot Harness 里跑着。按上面的说明准备好之后,输入:

/harness-rookie-wondering 我读完了“两道门”这一章。请教我这个 harness 是怎么搭出两道审批的(主题 9,以及讲权限的主题 8):为什么要在终端里敲,审批绑定的是什么,以及哪个 hook 会拒绝 agent。带我走一遍一个真实任务过两道关卡的过程,并画出来。

它一次只教一小块,停下来确认你跟上了,再和你一起打开文件。