
Meet your instructor and see what this course is about: an AI agent that can issue refunds and close accounts, and the controls that make it safe to ship. After this lecture, you know what you will build and whether this course is right for you.
See why an agent with tools is risky, and how we govern it with checks, approvals, limits and records. After this lecture, you can explain the plan of the course: one new control for Sam in each section, tested on the same five practice tickets.
Install Python 3.12 and uv, get the course code, and run Sam on your laptop with three commands. After this lecture, you can reset the shop, run the tests, and move to any section with its git tag, in replay mode with no API key.
Learn how every lecture, exercise and quiz works, and how to use replay mode as a safe place to practise. After this lecture, you know what to do after each section, and how to apply each control to an agent of your own.
Meet Sam, the support agent of a small online shop, and its four tools. After this lecture, you can explain the agent loop, run Sam in replay mode, and read the trace and the list of changes that a run made in the shop.
Watch Sam fail on five practice tickets: a wrong refund, the wrong customer, a stranger, a hidden instruction and a loop. After this lecture, you can explain why these failures happen, and why reading the agent's replies does not find them.
See why the real risk of an agent comes from its tools. After this lecture, you can rank any agent's tools with three questions: what can it change, how much in one call, and can we undo it. Includes the tool risk worksheet.
Build a short threat model for Sam: what could go wrong, how it happens, and which control stops it. After this lecture, you can list the four sources of harm for an agent and turn the threat model into a plan of controls. Includes the threat model template.
Give every run an identity: the agent, a run id, and the customer that it acts for. After this lecture, you can take the customer from the sender's address and never from the ticket text, so every later check knows who the agent acts for.
Describe every tool in one registry, with its kind, its risk and whether it can be undone, and send every call through one function. After this lecture, you can apply least privilege to tools, so a tool gets only the access and the data that it needs.
Make tool parameters narrow, like the boxes on a good form. After this lecture, you can use ids instead of names, check every argument with a schema before the tool runs, and explain why a schema alone cannot stop a wrong refund. Exercise 2 is in the resources.
Give every tool call its own credential with exactly one scope, so the shop itself refuses a call outside the tool's job. After this lecture, you can explain how scoped tokens limit the damage, and which two of the five failures are now fixed.
Put one guard in front of every tool call, so no call can go around it. After this lecture, you can return a decision with an effect, a rule and a reason, take the facts from the shop and not from the model, and make the guard fail closed.
Write the rules as data in a small policy engine, where every answer names the rule that gave it. After this lecture, you can write rules with an id, an effect, a test and a reason, and explain why deny wins over ask and ask wins over allow.
Write the same rules in Cedar, a policy language. After this lecture, you can read and write Cedar rules with a principal, an action, a resource and conditions, and check that the Python engine and Cedar give the same answer.
Test the guard with a table of cases that runs on both engines. After this lecture, you can write policy tests that are easy to read and extend, test that a broken guard always denies, and find a typo in a rule from a failing test. Exercise 3 is in the resources.
Learn the three answers of the guard: allow, deny and ask. After this lecture, you can decide when a call breaks a rule and must be denied, and when it is inside the rules but risky enough to ask a person first.
Decide which actions need a person before you build approval. After this lecture, you can use the tool's risk and the size of one call to choose between allow, ask and deny, so people are asked only when their decision really helps. Includes the approval matrix.
Pause a run when the guard says ask, and resume it after a person decides. After this lecture, you can save the exact call that waits, run it again through all the checks on resume, and make sure an approval is used only once.
Design an approval request that a person can really judge, like a payment form and not a blank cheque. After this lecture, you can show who asks, the exact call, the rule and the evidence from the shop, and make the request expire.
See why too many approval requests turn people into a rubber stamp. After this lecture, you can keep requests rare with limits, make one call create only one request, and watch the numbers that warn you that approvals are not read.
Keep a record of every approval: who asked, what, why, and the decision with its times. After this lecture, you can bind an approval to a fingerprint of the exact call, so it never fits another call, is used only once and expires. Exercise 4 is in the resources.
Stop runs that never end with limits that your own code checks. After this lecture, you can set a step limit and a time limit for each run, check them before every turn of the model, and stop the run with a clear reason in the trace.
Control what an agent spends with two token budgets: one per run and one per day. After this lecture, you can record the tokens of every turn, check both budgets before each turn, and choose a budget that allows for one last turn.
Catch an agent that repeats the same call again and again. After this lecture, you can stop a run when the same tool with the same arguments is called a third time, before the call reaches the shop, and explain why retrying a write is dangerous. Exercise 5 is in the resources.
Build a kill switch that lives outside the agent, which the agent cannot change. After this lecture, you can check it before every turn and every tool call, so it also stops paused runs, and keep a record of who turned it on.
Decide on purpose what happens when a check itself breaks. After this lecture, you can make the guard, the policy engine and the budget check fail closed, so nothing runs when we cannot check, and keep it that way with tests.
See how prompt injection works: text that gives instructions from a place that should only give data. After this lecture, you can find the places where an attacker can write text that your agent reads, in the request and in tool results.
Wrap untrusted text in tags that say where it comes from, and flag suspicious patterns in the trace. After this lecture, you can lower the risk of prompt injection, and explain why tags and flags are not enough on their own. Exercise 6 is in the resources.
Stop injected actions at the tool boundary. After this lecture, you can let the guard decide from facts in the shop and the run's identity, never from text that the model read, so the same rule blocks an attack in any words.
Learn the limits of every guardrail. After this lecture, you can explain what the guard does not stop, such as a false reply, and design your tools so that the worst thing an attacker can make the agent do is still acceptable.
Decide what to record for every step of a run, like a flight recorder. After this lecture, you can record who acted, what happened, who decided and the result, include the blocked calls, and keep secrets and personal data out.
Write the audit log as structured events that a program can search and count. After this lecture, you can use JSON Lines with a small set of event kinds, and record every control's decision in the same field. Includes the audit event schema.
Chain the audit events with hashes, so a changed or deleted event is found. After this lecture, you can build a hash chain, verify it with one command, and explain why it is tamper-evident but not tamper-proof.
Keep personal data out of the audit log. After this lecture, you can log ids instead of values, redact emails, names and addresses before an event is written, and still prove the exact call with a hash. Exercise 7 is in the resources.
Rebuild what happened in a run from its audit log, without the model and without the shop. After this lecture, you can replay any run, see a changed log in the replay, and prove with a test that the replay matches the real run.
Test that every control is really in place, not only that each piece works. After this lecture, you can write governance tests that run next to your unit tests, for example a test that replaces the guard with one that denies everything.
Build an attack test suite with variants of every practice attack. After this lecture, you can write invariants, which are things that must never happen in the shop, run every attack against them, and test that the suite itself finds problems.
Run all the governance checks in CI, so a broken control blocks the release. After this lecture, you can set up a release gate as a required check for the main branch, and see it catch a small change to a limit. Exercise 8 is in the resources.
Watch what your controls do in production. After this lecture, you can count denials, approvals, stops, injection flags and spend from the audit log with one command, and decide which changes should raise an alert.
See what the EU AI Act, the NIST AI RMF, ISO/IEC 42001 and the OWASP Top 10 for LLM Applications ask engineers for. After this lecture, you can map those requests to evidence: risks, human oversight, a way to stop, logs, security, tests and monitoring. Includes the evidence pack template.
Show each control with three kinds of evidence: the code, the test, and a record from a real run. After this lecture, you can keep the control map as data that reads its file and line numbers from the code, so it never goes stale.
Build an evidence pack from the code, the tests and the audit log with one command. After this lecture, you can produce a pack that shows a broken control, and rebuild it on every change in the release gate.
This course contains the use of artificial intelligence. The scripts, visuals and audio editing were prepared with the help of AI tools. Every lecture is narrated in my own voice, and I designed the course and the project and reviewed every lecture.
An AI agent that can only talk is easy to live with. An agent that can issue refunds, change customer records and close accounts is different: when it makes a mistake, the mistake is an action, and very often nobody checks it before it happens.
In this course, you take Sam, the support agent of a small online shop, from "it works in the demo" to "we can ship it". In the first section, Sam fails on five practice tickets: it refunds two thousand dollars instead of twenty, closes the wrong customer's account, gives an address to a stranger, obeys an instruction hidden in a ticket, and burns its budget in a loop. In every section after that, you add one control in plain Python and replay the same tickets to see it work:
an identity for every agent and every run, and one scoped credential per tool
a guard before every tool call, with the rules written as code and in Cedar, and tested
human approval for risky actions, without approving everything by hand
step limits, cost budgets, loop detection and a kill switch that really stops the agent
defences against prompt injection that check actions, not words
a tamper-evident audit trail that you can replay
a test suite and a release gate in CI that block a release when a control breaks
an evidence pack that maps your controls to what the EU AI Act, NIST AI RMF, ISO/IEC 42001 and OWASP ask for
Everything runs on your laptop. The project ships with recorded model answers, so you need no API key and pay nothing to follow along; a live mode works with any OpenAI-compatible endpoint when you want it.
The course ends with a capstone: you govern a second agent on your own, and review it with the same checklist that we use for Sam.
This course teaches engineering controls and how to show evidence for them. It is not legal advice.