我批准 Agent 刪除客戶,但它仍然拒絕
I Approved My Agent to Delete a Customer. It Still Said No.
Bobby Hall Jr 在 Ship a Safe Agent Module 1 示範,權限檢查會先拒絕標記為 deny 的 delete_customer,即使該操作已獲批准亦然。
I clicked Approve on delete_customer. My agent refused anyway.
That is the behavior I want, and it comes from five lines of code where the only trick is the order.
The problem with "a human approved it"
Most agent safety ends at one question: did someone click Approve? That turns your most destructive action into one tired click. Approve the refund, approve the lookup, approve the delete. Oops.
Three permissions, not two
In Module 1 of Ship a Safe Agent, every tool is registered with a permission:
-
allow:
lookup_order,track_package -
ask:
issue_refund -
deny:
delete_customer
The check, and why order matters
export function checkPermission(tool: Tool, approved: Set<string>): Verdict {
if (tool.permission === "deny") return { ok: false, reason: "denied" };
if (tool.permission === "ask" && !approved.has(tool.name)) return { ok: false, reason: "needs approval" };
return { ok: true };
}
Deny is checked before approvals are even read. Here is the step's expected output:
lookup_order no approval: ok approved: ok
issue_refund no approval: needs approval approved: ok
delete_customer no approval: denied approved: denied
track_package no approval: ok approved: ok
Approval unlocks "ask". It can never unlock "deny". Swap the first two lines and one click deletes a customer. No prompt fixes that. Code order does.
Run it yourself
git clone https://github.com/bobbyhalljr/ship-a-safe-agent-module-1
cd ship-a-safe-agent-module-1
npm install
npm run check
No API key. The model is scripted, so every run is deterministic, and each step has an expected.txt to diff against.
The rest of Module 1
After permissions you add skills that keep tools invisible until loaded, a scripted model, runAgent with a step budget, and a replayable event log. Then 3 graded exercises; npm test fails until you finish them.
Get it
來源:DEV Community · dev.to