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 };
}
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

  • Start free: Module 1
  • Full course: $149 until Nov 8 (then $199), 14-day refund: buy here