Bobby Hall Jr 推出 Ship a Safe Agent 智能體安全課程,Module 1 免費
I built a course on shipping AI agents that can't hurt you. Module 1 is free.
Bobby Hall Jr 推出 Ship a Safe Agent,一門以 TypeScript 建構安全支援智能體的實作課程;Module 1 免費,無需 API key,並可離線完成。
Your agent will try to do something you never meant to allow. It will refund an order nobody approved, call a tool it should not see, or loop until the bill gets your attention. Prompts do not stop that. Code does.
That is why I built Ship a Safe Agent, a hands-on TypeScript course where you build one support agent and every safety layer it needs before it touches real systems.
Who it is for
Developers who know TypeScript, Node, async, JSON and git. No ML background. No API key either: the model in every module is scripted, so every run is deterministic and testable. You can run the whole course offline.
Module 1, step by step (free)
Module 1 is "the loop". One agent, one context, limits in the harness. About 75 minutes. The agent handles a customer who wants a refund for order 1042.
git clone https://github.com/bobbyhalljr/ship-a-safe-agent-module-1
cd ship-a-safe-agent-module-1
npm install
npm run check # typecheck + every step matches its expected output
Each folder in steps/ is the full code after that step, with an expected.txt you can diff against.
-
Tool registry. Every tool ships with a permission.
lookup_orderandtrack_packageare allow,issue_refundis ask,delete_customeris deny. Duplicate names throw. -
Permissions.
checkPermissionreturns ok, needs approval, or denied. Deny stays denied even when approved. -
Skills and context. Tools are invisible until a skill loads. Before: none. After loading
refunds:lookup_order, issue_refund. The refund policy text rides in with the skill. -
A fake model. A scripted model returns turns like
{"kind":"load_skill","name":"refunds"}, so you test the harness, not the prompt. -
The loop.
runAgentwith a step budget and approvals. Without approval the run ends withblocked issue_refund: needs approval. - The event log. A readable, replayable log. Same task, three runs:
run 1: no approval BLOCKED issue_refund: needs approval
run 2: refund approved result refunded $48.00 on order 1042
run 3: step budget 2 answer Stopped: step budget of 2 reached.
The graded exercises
Open exercise/agent.ts and replace three TODOs:
-
shippingModel: answer "Where is my package?" using only the shipping skill. -
runAgentWithBudget: stop aftermaxToolCallstool calls. -
summarize: turn an event log into a summary.
npm test runs 5 checks and fails until you finish. One of them proves the refund tools never become visible during a shipping question. Stuck? git diff main solution -- exercise/agent.ts.
Modules 2 to 8
- 2. Trust the output. Strict schemas, one repair then fail, act/ask/skip thresholds in code.
- 3. Gate the actions. A shell gate that refuses what it cannot parse, confirms bound to the exact payload, middleware that redacts secrets.
- 4. Untrusted input. Emails and documents as data, not instructions. Replay real attacks as regression tests.
- 5. Identity and secrets. Zero secrets in the sandbox, short-lived scoped grants, default-deny egress.
- 6. Cost and model choice. Price every call, route to the cheapest fit, caps that pause instead of fail.
- 7. Long-running agents. Suspend at every tool call, resume only from signed events, know when to stop.
- 8. Observe, evaluate, ship. Trace every run, evals scoped to behavior, a CI gate that fails when a gate goes missing.
Every module follows the same pattern as Module 1: steps with expected output, then graded exercises.
Get it
- Start free: Module 1 and the repo.
- Get the full course: $149 founding price until Nov 8 (then $199), lifetime access, 14-day refund: buy here.
Build the loop first. Decide after.
來源:DEV Community · dev.to