agents · Level 4
Running AI Agents Safely in Production
The boundaries, budgets, gates and incident response a production AI agent actually needs, worked through on one invented company throughout: for CTOs, developers, platform engineers and agent orchestrators.

Your next step
Start this course online
Register your start, then work through the lessons and exercises at your own pace. You can download the PDF separately. Where a scored exam is available, you will find it after the lessons.
Register or resume your course
Start with the essentials
The short answer
Running AI agents safely in production means treating deployment as an engineering discipline, not a bigger demo: give the agent its own identity, scope its tools to a written list of actions it must never take alone, bound its network, data, cost and time, log its decisions without exposing secrets, gate every release against adversarial tests, and rehearse how you would contain and recover from an incident.
What you will learn
- You will be able to map an AI agent's production boundaries (identity, tools, network and data, cost and time, visibility) and name a concrete control for each.
- You will be able to design least-privilege tool access for an agent, including a written never-list and a human-approval threshold enforced in code.
- You will be able to set budgets, rate limits, timeouts and a circuit breaker that actually stop a runaway agent, not just report on it afterwards.
- You will be able to build a logging scheme that supports incident response without exposing secrets or sensitive data.
- You will be able to define release gates and a monitoring plan that catch unsafe output and drift, before and after an agent goes live.
- You will have produced a production-readiness dossier, a test plan and a rehearsed incident-recovery exercise for an agent, and be able to explain what that exercise does and does not prove.
Who it is for
CTOs, developers, platform engineers and agent orchestrators who already have an AI agent working in a demo or an early deployment and need to take it into real production use, carrying real data, real cost and real consequences. No specific programming language is required: the method applies whatever stack your agent runs on.
Before you start
- A working AI agent, or a concrete plan for one. This course assumes you already understand what an agent is and does, as in What is an AI agent? Agentic AI explained, and picks up from there: what changes once an agent leaves a demo.
- Enough familiarity with your own organisation's systems to identify its identity provider, secrets store, network setup and logging, so the exercises can be applied to a real agent rather than only to the worked example.
Learn in your browser · Chapter 01 of 09
From demo to production: architecture and boundaries
A demo agent proves an idea works once, with you watching. A production agent has to keep working, unattended, against real systems and real people, carrying whatever access you gave it. This chapter sets out that shift and the five boundaries the rest of this course builds, one at a time.
A demo usually runs on a laptop, uses one developer's own broad credentials, touches a handful of fake or low-stakes records, and stops the moment the terminal window closes. Production is the opposite on every count: the agent runs repeatedly and unattended, it needs its own scoped identity rather than borrowing yours, it reaches real customer data and real money, and it keeps running long after you have stopped watching it. None of that is a reason to avoid shipping agents. It is a reason to design deliberately for what changes.
Five boundaries recur across nearly every serious agent incident: identity (who is the agent, provably, and can that be revoked on its own), tools (exactly which actions it may take, and with what limits), network and data (what it can reach, and what it can read or write), cost and time (what stops it if something goes wrong and it keeps trying), and visibility (whether anyone can reconstruct what it did afterwards). Chapters 2 to 9 take these in turn, plus how you decide an agent is ready to ship and how you recover when something still goes wrong.
- Identity: could this agent's access be revoked on its own, without touching anyone else's account?
- Tools: does it hold any permission its actual task does not need, kept just in case?
- Network and data: can its runtime reach anything beyond the specific systems and data it was built to use?
- Cost and time: what concretely stops it if it starts calling a tool in a loop?
- Visibility: could you reconstruct exactly what it did and decided last week, from the logs alone?
The rest of this course follows one invented example throughout: Thornfield Logistics, a fictional parcel courier, and Wayfinder, the AI agent it built to handle customer delivery queries, reschedule deliveries and issue small goodwill credits. Every name, figure and log line attached to Thornfield and Wayfinder is invented for teaching. Read them as a template to hold your own agent against, not as a real company's data.
Scroll sideways to see every column.
| Boundary | Wayfinder's demo | Wayfinder's production target |
|---|---|---|
| Identity | Ran under an engineer's own API key | Its own scoped service identity, revocable alone |
| Tools | Could call every internal API the demo script imported | A named allow-list, plus a written never-list |
| Network and data | Ran on a laptop with open internet access | Reaches only the orders and credit APIs, nothing else |
| Cost and time | No limit; a developer watched and stopped it by hand | A spend cap, a call limit and a timeout per session |
| Visibility | Printed to a terminal nobody kept | Structured logs kept and queryable after the fact |
Try it yourself · Activity 01
15 minScore your own agent's five boundaries
Pick an AI agent you already run, or plan to: something beyond a one-off demo.
- For each of the five boundaries, write one sentence stating its current, real state, not the intended one.
- Mark each boundary green (a concrete control exists), amber (partial or unverified) or red (no control).
- Pick the single reddest boundary and write one sentence on what you would do about it this week.
Which boundary were you least able to answer with confidence, and what does that tell you?
Worked answer
There is no single right answer here: the exercise is diagnostic. A common honest pattern for a team's first production agent is green on tools (a deliberately built allow-list) but red on identity (still running under a shared or personal credential) and amber on visibility (some logs exist, but nobody has tried to reconstruct a week from them). If every boundary came back green on a first pass, treat that as a prompt to check more sceptically, not as confirmation you are finished.
Learn in your browser · Chapter 02 of 09
Identity and secrets: who the agent is, and what it holds
An agent that runs as whoever happened to be logged in cannot be scoped, logged or revoked on its own. Give it an identity of its own before you give it anything to hold.
A service identity is a distinct identity issued to the agent itself, separate from any human user and separate from any other agent or service. It matters because access, logs and revocation all attach to an identity: if Wayfinder shares an engineer's personal token, disabling Wayfinder means disabling that engineer, and every action Wayfinder ever took shows up in that person's own audit trail, indistinguishable from their own work.
Secrets are the credentials, keys and tokens an identity uses to prove itself and reach other systems. The house rule is simple to state and easy to get wrong under deadline pressure: a secret lives in a vault or a short-lived token issuer, never in a prompt sent to a model, never committed to a script, and never printed to a log in plain form. A model that has read a secret in its context can repeat it in an output; a log that stored one in plain form is a second copy sitting wherever that log is stored, backed up and, eventually, forgotten about.
- Issue the agent its own service identity, distinct from any person's account.
- Scope that identity's credentials to exactly the systems the agent's tools need to reach.
- Source secrets from a vault or a short-lived token issuer at runtime, never from a file the agent's own code or prompt can read wholesale.
- Set an expiry and an automatic rotation on every credential the identity holds.
- Write down, in one place, how to revoke that identity alone, without touching any other identity.
Thornfield gives Wayfinder the service identity svc-wayfinder-prod. It authenticates to the orders and credit APIs with a token issued for fifteen minutes at a time by Thornfield's internal token service; the token itself is never stored anywhere Wayfinder's own logs or prompts could echo it, only a short, non-secret reference such as token-ref: 8f2c-... appears in a log line. When a security review later needs to revoke Wayfinder's access on its own, one operator disables svc-wayfinder-prod, and nothing else in Thornfield's systems is affected.
Try it yourself · Activity 02
12 minTrace one credential
Pick one credential your own agent, or a planned one, currently uses.
- Write down exactly what it can do if fully misused: every system and action it reaches, not just the intended one.
- Check whether it expires, and if so, how often it is rotated.
- Check whether it could appear in plain form in a log, a prompt sent to a model, or a script file.
If that credential leaked today, what is the single worst thing it could be used to do, and would you know it had leaked?
Worked answer
A useful pass mark: you can name the worst-case action precisely, not just lots of things, the credential expires in hours rather than months, and you have a concrete way to find out it leaked, such as an alert on unusual use, rather than hoping someone notices. If you cannot answer at least two of those three, treat the credential as an open boundary.
Learn in your browser · Chapter 03 of 09
Least-privilege tool access: designing what an agent may do
Every tool you give an agent is a door. Least privilege means the agent should be able to open exactly the doors its task needs, and nothing else, no matter how convenient it would be to leave a few more unlocked.
Interactive case study · Fictional policy
Where does the agent have to stop?
Wayfinder may issue credits up to £50. Larger credits need fresh approval for that exact action. Deleting backups and exporting customer data are outside this agent's authority. No real action is performed.
- Agent proposalNo authority yet
- Policy gateCheck identity, scope and limits
- DecisionBlock, hold or permit before a side effect
A valid identity and an in-scope credit up to £50 may proceed. Anything outside scope is blocked; larger credits wait for specific approval.
Presence is not permission. Changing the proposal or identity invalidates the simulated approval. This teaching model omits real authentication, race prevention and signed approval evidence.
Least privilege is an old computer-security idea, older than AI agents: give any user, program or agent the smallest set of permissions that lets it do its actual job. Applied to an agent, this means scoping three things separately: which tools it can call, what arguments or ranges it may pass to each one, and which of those technically-reachable actions it must never take without a person's approval.
- Is the action reversible, such as a read, a draft or a reschedule, or hard to undo, such as a delete, a payment or a message sent to a real person?
- Could a single call, on its own, cause serious harm if the agent's reasoning happens to be wrong that one time?
A never-list is different from a permission list. A permission list says what the agent CAN reach. A never-list says which of those reachable actions it must never actually carry out alone, even though it technically has the access. An agent might genuinely need broad read access to serve customers well, and still be told, in a way the system enforces rather than merely documents: never issue a credit above a stated limit, never delete a record, never send a message outside an approved template, without a person approving first.
- List every tool the agent can call, including ones inherited from a shared library it happens to import.
- For each tool, write the narrowest scope that still lets it do its job: a maximum amount, a specific record type, a read-only mode where writing is not needed.
- Write a never-list: actions the agent must never take without a person approving, enforced in the tool itself, not only in a prompt instruction.
- Set the approval threshold: the point above which a person must say yes before the action runs.
- Review the list again once the agent has been live for a month; real use reveals tools nobody remembers granting.
Scroll sideways to see every column.
| Wayfinder's tool | Scope | Never without a person's approval |
|---|---|---|
| read_order | Read-only, one order at a time | Not applicable: read-only |
| reschedule_delivery | Within the same postcode area, next 14 days | Rescheduling outside that window |
| issue_credit | Up to 50 pounds per case | Any amount above 50 pounds |
| escalate_to_human | Always available | Not applicable: escalation is always allowed |
Try it yourself · Activity 03
15 minWrite a never-list
For an agent you run or plan to, Wayfinder or your own, list every tool it can call.
- Mark each tool reversible or hard-to-undo.
- For every hard-to-undo tool, write one never-list rule and where it would be enforced, in the tool's own code, not just a prompt.
- Pick one rule and describe, in one sentence, how you would test that the enforcement actually works, not just that the rule is written down.
Is any rule on your never-list currently enforced only by a prompt instruction, rather than by code the agent cannot talk its way around?
Worked answer
A prompt instruction such as never issue more than the limit is not enforcement: an unusual enough conversation can talk a model past its own instructions. Real enforcement checks the amount in code, in the tool itself, before the action runs, and rejects anything over the limit regardless of what the model asked for. If your never-list rules live only in prompt text, that is the gap to close first.
Learn in your browser · Chapter 04 of 09
Network and data boundaries: containing the blast radius
Identity says who the agent is; tool scope says what it may do. This chapter is about what it can physically reach: which systems its network traffic can touch, and which data it is allowed to read or write.
Blast radius is the extent of damage a single failure, a bug or a compromised credential can cause, because of what it can reach. An agent with narrow tool scope can still have a huge blast radius if its runtime sits on a network that can reach everything, or if the data it can write to includes things far beyond its job.
Egress control restricts which external addresses or systems a running agent's network traffic may reach at all, regardless of what its own code tries to do. Pair that with environment isolation: an agent built and tested against staging data should not be able to reach production systems by accident, and a production agent should not be able to reach the wider internet unless a specific tool genuinely needs it.
- Write an egress allow-list: the specific systems the agent's runtime may reach, nothing implied or inherited from the wider network.
- Isolate environments: staging credentials and data must not be reachable from a production agent, and vice versa.
- Classify the data the agent can read or write, and redact or exclude anything outside what its task needs before it reaches the model.
- Store backups behind a different identity and, where possible, a different resource than the live data they protect.
- Test the boundary by trying to reach something outside it deliberately, in a safe environment, rather than assuming the configuration works.
Wayfinder's runtime can reach only two internal addresses: the orders API and the credit-issuing API, both over Thornfield's internal network. It cannot reach the customer database directly; it reads orders through the API, which enforces its own field-level limits. It cannot reach the public internet, and it cannot reach Thornfield's backup storage at all, because backups are managed by a separate system under a separate identity that Wayfinder's service identity was never granted.
Try it yourself · Activity 04
15 minMap one agent's reachable surface
For an agent you run or plan to, list every system its runtime can technically reach on the network, not just the ones it is meant to use.
- Include anything reachable by inheritance: a shared network, a broad DNS allow-list, a container image with wider access than the agent's own code uses.
- Mark anything on that list the agent's actual task does not need.
- Check specifically: can this agent's identity reach a backup of the same data it can write to?
Did anything on your reachable list surprise you?
Worked answer
The most common surprise is inherited network access: an agent deployed into a shared cluster or virtual network can often reach far more than its own tool list suggests, because the boundary nobody configured was the network, not the tools. The backup question usually surfaces a genuine gap on a first pass: many teams have never checked whether their agent's own identity can reach its own backups.
Learn in your browser · Chapter 05 of 09
Budgets, rate limits and timeouts: keeping cost and time bounded
Every other boundary in this course limits what an agent can do. This one limits how much and how long, so a bug or a bad loop cannot turn a small mistake into an expensive one.
Four controls work together here. A budget caps total spend, in money, tokens or tool calls, over a session or a day. A rate limit caps how often a tool can be called in a given window, independent of total spend. A timeout caps how long any single step, or the whole loop, is allowed to run before it is stopped regardless of what it is doing. A circuit breaker is the mechanism that actually enforces a limit once it is crossed, killing the session rather than logging a warning and continuing.
A budget without a circuit breaker is just a number in a dashboard: useful for reporting after the fact, useless for stopping damage while it happens. The breaker has to be able to end the session, not merely flag it, and it has to fire before the limit is exceeded by a wide margin, not after a bill arrives.
- Set a per-call timeout: the longest any single tool call may run before it is treated as failed.
- Set a per-session limit: total calls, tokens or spend allowed before the session ends automatically.
- Set a per-day or per-organisation budget as a second, wider net above individual sessions.
- Build the circuit breaker to end the session on breach, not just to log or alert.
- Alert a person immediately when a breaker fires, with enough detail, such as the session identifier and what was being attempted, to investigate without reproducing the loop.
Scroll sideways to see every column.
| Limit | Wayfinder's setting (invented) |
|---|---|
| Per-call timeout | 10 seconds |
| Per-session call budget | 40 calls |
| Per-session spend cap | 2 pounds of model and tool cost |
| Daily organisation budget | 150 pounds |
Try it yourself · Activity 05
15 minDesign a circuit breaker
For an agent you run or plan to, design the four controls in this chapter.
- Pick a per-call timeout appropriate to the slowest tool call it genuinely needs.
- Pick a per-session budget: state the actual number and the unit, calls, tokens or currency.
- Write, in one sentence, exactly what happens when the budget is crossed: what stops, and who is told.
- State how you would find out a breaker fired without watching a dashboard continuously.
If your agent's cost doubled overnight through a bug, how long would it run before anything stopped it, today, honestly?
Worked answer
A useful pass mark: you can give an actual number of minutes or sessions, not someone would probably notice. If the honest answer is until the monthly bill arrives, or until a person happens to look, the budget exists on paper but the circuit breaker does not exist in practice.
Learn in your browser · Chapter 06 of 09
Logging that protects sensitive data
A log is how you find out what an agent did after the fact, which matters most exactly when something has gone wrong and you were not watching live. It only helps if it exists, is structured, and does not itself become a second place sensitive data leaked to.
Log enough to reconstruct a decision: what the agent was asked, which tools it called and with what arguments, what each tool returned, what it decided, and when, tagged with the identity that acted. Log too little and an incident review becomes guesswork; log too much, in the wrong form, and the log itself becomes a liability.
Redaction means removing or masking sensitive values before they are stored or displayed: a card number becomes a masked string, a full address might become a postcode, a secret token never appears at all, only a short non-secret reference to it. Redact before the value is written to the log, not after: a log that briefly held the real value and was cleaned up later has already been copied to backups, forwarded to a monitoring tool, or read by someone, by the time the clean-up runs.
- Decide what every log line must contain to support an incident review: actor identity, action, arguments, result, timestamp.
- List the fields that must never appear in plain form: secrets, full payment details, health data, anything your organisation classifies as sensitive.
- Redact or hash those fields before the line is written, not in a later clean-up pass.
- Set a retention period matched to purpose: incident-response fields kept longer, raw sensitive content kept only as long as genuinely needed, or not at all.
- Restrict who can read the logs to those who need them for operations or investigation, separate from broader system access.
{
"ts": "2026-09-15T14:02:11Z",
"identity": "svc-wayfinder-prod",
"tool": "issue_credit",
"args": {"order_ref": "TL-88213", "amount_gbp": 15.00},
"result": "approved",
"token_ref": "8f2c-...",
"card_field": "REDACTED"
}Try it yourself · Activity 06
12 minRedesign one log line
Find one real log line your own agent, or system, currently produces.
- List every field in it.
- Mark any field that is, or could contain, a secret or sensitive personal data.
- Rewrite the line with those fields redacted or removed, keeping enough to still investigate an incident.
Could you explain, from this log line alone, what happened and why, a month from now, without any secret or sensitive value being exposed to whoever reads it?
Worked answer
The test is specific: someone with legitimate access to investigate an incident should be able to reconstruct the decision from the log alone, while someone who should not see a customer's card number or a live secret genuinely cannot, because those values were never written in plain form, not because access happens to be restricted today.
Learn in your browser · Chapter 07 of 09
Evaluation and release gates: deciding when an agent is ready to ship
A demo that worked once is not evidence an agent is safe to ship. A release gate is a stated, checked bar a new version has to clear before it reaches real users, and it only works if the evaluation behind it includes the cases that actually break things.
An evaluation set is a fixed collection of realistic inputs, with a known good, or known unacceptable, outcome for each, run against every candidate version before release. A useful set mixes ordinary cases, most of real traffic, with adversarial ones deliberately built to provoke a bad response: an attempted prompt injection, a request just outside the agent's remit, an ambiguous instruction a careless version might over-comply with.
A release gate turns that evaluation into a decision rule: a stated pass threshold, for example a minimum overall score and zero tolerance for any critical-severity failure, that a version must clear before it is allowed to reach real traffic. An evaluation without a gate is just a report nobody has to act on; a gate without adversarial cases in the set behind it mostly proves the happy path still works, which is the part least likely to have broken.
- Collect or write realistic ordinary-case inputs covering the agent's actual range of use.
- Add adversarial cases deliberately: hidden instructions, edge-of-remit requests, ambiguous phrasing that invites over-compliance.
- Score each case by severity, not just pass or fail: a wrong tone is not the same severity as an unapproved credit.
- Set the gate: a stated overall threshold, plus zero tolerance for any critical-severity failure, both checked automatically.
- Stage the rollout after the gate: a small percentage of real traffic first, a canary rollout, widened only once that stage looks clean too.
This is also where NIST's AI Risk Management Framework is most directly useful, not as a certification but as a structure. NIST's framework describes four functions: GOVERN (culture, policies, accountability), MAP (understanding context and risks), MEASURE (evaluating them, which is exactly what a release gate does) and MANAGE (treating them). It is voluntary guidance, not a legal requirement or a certification, and NIST's own site noted on 29 September 2026 that AI RMF 1.0 is being revised, so check the current framework text before treating any specific control inside it as final.
Try it yourself · Activity 07
20 minAdd three adversarial cases
For an agent you run or plan to, look at its current evaluation set, or start one if none exists.
- Write three adversarial cases specifically: an input containing hidden instructions, a request just outside the agent's stated remit, and an ambiguous instruction that invites over-compliance.
- State, for each, the response you would classify as a critical-severity failure.
- Write the gate rule your agent's next release should have to clear, including what happens automatically if it fails.
Would your current evaluation set, honestly, have caught the three cases you just wrote, if they existed before today?
Worked answer
Most teams' first honest answer is no: an evaluation set built only from real historical traffic tends to contain mostly ordinary cases, because adversarial ones are rare in normal use even though they matter disproportionately when they occur. Writing them deliberately, rather than waiting for one to show up in production, is the actual point of this exercise.
Learn in your browser · Chapter 08 of 09
Monitoring, drift and dependency review
A release gate checks a version before it ships. This chapter is about the agent you already shipped: watching it for change you did not make, and reviewing the things it depends on before they change under you.
Drift is a live agent's behaviour changing over time because the model, an upstream API, or the data it reads has changed, without the agent's own code changing at all. It is quieter than a bug: nothing failed loudly, the agent simply started behaving a little differently, and by the time someone notices, it may have been happening for weeks.
Monitoring an agent in production means watching metrics that would show drift or a developing problem before a person happens to read a transcript: error and escalation rates over time, latency, cost per session, and the share of sessions that hit a boundary from earlier chapters, such as a never-list rule triggered or a budget breaker fired. A sudden change in any of these, even without an outright failure, is worth investigating.
- Track error rate, escalation rate, latency and cost per session over time, not just as a single current number.
- Alert on a meaningful change in any of those, not only on an outright failure.
- Make every external tool call fail closed by default: an unexpected response escalates to a person rather than being guessed at.
- Set a freshness check on any data source the agent relies on that changes outside its own release process.
- Review each dependency, the model provider, every tool API, every library, on a fixed schedule: read its changelog, check its terms have not changed, confirm the version in use is still supported.
Try it yourself · Activity 08
15 minPick one dependency and review it
List every external thing an agent you run or plan to actually depends on: the model provider, each tool API, each library.
- Pick the one you have reviewed least recently.
- Find its current changelog or release notes and read the most recent entries.
- Note anything that changed that your agent's code has not been updated to account for.
When did you last actually read a changelog for a dependency your agent relies on, rather than just updating a version number?
Worked answer
For most teams the honest answer is not recently, if ever, for at least one dependency, usually a library rather than the model provider. The exercise's point is that a dependency review is an active reading task, not something that happens automatically because a version number was bumped.
Learn in your browser · Chapter 09 of 09
Graceful failure, incident containment and recovery: your capstone
Every boundary in this course can still fail. This chapter is about what happens next: failing in a way that limits harm, containing an incident fast, and recovering cleanly, then applying all of it in one capstone exercise.
Graceful failure means choosing, in advance, whether an agent should fail closed, stop and escalate to a person, or fail open, continue with reduced function, for each kind of failure, rather than discovering the answer live during an incident. As a rule of thumb: fail closed for anything hard to undo, a payment, a delete, a message to a real person; fail open only for things that are safe to get slightly wrong and easy to correct later, a slightly delayed response, a lower-confidence suggestion clearly marked as such.
Incident containment is the immediate response once something has gone wrong: stop the specific harm from continuing, before investigating why it happened. For an agent, that usually means one of: pausing the agent entirely, revoking or rotating the specific credential involved, or lowering an approval threshold to zero so nothing proceeds without a person, exactly as the compromised-tool response in an earlier chapter did.
- Detect: an alert, a report or a monitoring signal says something is wrong.
- Contain: stop the specific harm continuing, pause the agent, revoke the credential, drop the threshold, before anything else.
- Diagnose: read the logs to reconstruct what happened, only once containment is in place.
- Recover: roll back to the last known-good version, or fix forward if rolling back is not possible, and confirm normal operation before wider release.
- Review: write down what happened, what caught it, what did not, and what changes as a result, and keep that record.
Rollback and change control work together: rollback only works cleanly if the previous version is genuinely still available and known to have been good, which is why the release gate matters: a version that never passed the gate should never be the last known good. Change control is the written process that decides, approves, records and reviews any change before it goes live, so there is always a specific prior version to roll back to.
Try it yourself · Activity 09
60 minCapstone: production-readiness dossier, test plan and incident-recovery exercise
Bring together everything from this course for one agent, real or Wayfinder.
- Dossier: for each of the five boundaries from chapter 1, identity, tools, network and data, cost and time, visibility, write the concrete control in place today, in one sentence each, citing where it is enforced.
- Test plan: list what you would check before this agent's next release: its evaluation set and gate, its budget and circuit breaker, and one deliberate failure-injection test, forcing a tool call to fail and confirming it fails closed.
- Incident-recovery exercise: run the compromised-tool scenario from the least-privilege chapter as a tabletop walkthrough. Starting from a credential may have leaked, write out each runbook step from this chapter as you would actually carry it out, including who you would actually contact and how long each step should honestly take.
- State your dossier's single weakest boundary, and one concrete action that would close it, with an owner and a date.
If this exact incident happened for real tomorrow, is your runbook something your team could follow under pressure, or something that only makes sense reading it calmly today?
Worked answer
A dossier that passes its own honest test names a real control for every boundary, not an aspiration; a test plan that passes names an actual failure-injection test that was or will be run, not merely described; and a runbook that passes the pressure test names real people or roles, not an abstract security team, and gives times that assume someone is asleep, not that everyone is at their desk. If the runbook only works when read calmly, rehearse it once for real, on a fixture, before treating it as done.
Thornfield and Wayfinder in this course are invented, but the shape of the problem is not: a real production agent needs its identity, tools, network, cost and visibility boundaries actually built and actually tested, not sketched once and left. If your organisation is past the point of learning this and into the point of needing an agent's boundaries, logging and release gates actually built, tested and maintained, Mickai builds bespoke AI workflows and code enhancements for companies, running on Mickai's own sovereign operating system with zero data egress: your systems, your data and your agent's own logs never leave your own environment. See what that looks like at mickai.co.uk/bespoke.
Keep learning
The complete workbook
This elite-tier workbook is for CTOs, developers, platform engineers and agent orchestrators taking an AI agent beyond a laptop demo and into real production use. Working through one invented company, Thornfield Logistics, and its agent Wayfinder, you will design identity and secrets handling, least-privilege tool access, network and data boundaries, budgets and circuit breakers, protected logging, release gates, drift monitoring and dependency review, and a rehearsed incident-recovery runbook. The capstone produces a production-readiness dossier, a test plan and an incident-recovery exercise for an agent of your own.
- 01From demo to production: architecture and boundariesRead here · 1 exercise
A demo agent proves an idea works once, with you watching. A production agent has to keep working, unattended, against real systems and real people, carrying whatever access you gave it. This chapter sets out that shift and the five boundaries the rest of this course builds, one at a time.
- 02Identity and secrets: who the agent is, and what it holdsRead here · 1 exercise
An agent that runs as whoever happened to be logged in cannot be scoped, logged or revoked on its own. Give it an identity of its own before you give it anything to hold.
- 03Least-privilege tool access: designing what an agent may doRead here · 1 exercise
Every tool you give an agent is a door. Least privilege means the agent should be able to open exactly the doors its task needs, and nothing else, no matter how convenient it would be to leave a few more unlocked.
- 04Network and data boundaries: containing the blast radiusRead here · 1 exercise
Identity says who the agent is; tool scope says what it may do. This chapter is about what it can physically reach: which systems its network traffic can touch, and which data it is allowed to read or write.
- 05Budgets, rate limits and timeouts: keeping cost and time boundedRead here · 1 exercise
Every other boundary in this course limits what an agent can do. This one limits how much and how long, so a bug or a bad loop cannot turn a small mistake into an expensive one.
- 06Logging that protects sensitive dataRead here · 1 exercise
A log is how you find out what an agent did after the fact, which matters most exactly when something has gone wrong and you were not watching live. It only helps if it exists, is structured, and does not itself become a second place sensitive data leaked to.
- 07Evaluation and release gates: deciding when an agent is ready to shipRead here · 1 exercise
A demo that worked once is not evidence an agent is safe to ship. A release gate is a stated, checked bar a new version has to clear before it reaches real users, and it only works if the evaluation behind it includes the cases that actually break things.
- 08Monitoring, drift and dependency reviewRead here · 1 exercise
A release gate checks a version before it ships. This chapter is about the agent you already shipped: watching it for change you did not make, and reviewing the things it depends on before they change under you.
- 09Graceful failure, incident containment and recovery: your capstoneRead here · 1 exercise
Every boundary in this course can still fail. This chapter is about what happens next: failing in a way that limits harm, containing an incident fast, and recovering cleanly, then applying all of it in one capstone exercise.
Also inside: a 9-point checklist, a glossary of 12 terms and 12 questions and answers to test yourself. 9 hands-on exercises, each with a worked answer at the back where the workbook gives one.
The PDF is free. We ask for your name and email before downloading. Read the privacy notice at the download form. Free to download and use for personal learning, study groups and inside your own team. Please do not resell the workbooks or republish them as your own. Link people to trust-agent.ai instead.
Get your free PDF workbook
Enter your name and email, then download the complete workbook. This form also works without JavaScript.
Test yourself
Questions and answers
What actually changes when an agent moves from a demo to production?
A demo runs once, on a laptop, under a developer's own broad credentials, and stops when the developer stops watching. A production agent runs repeatedly and unattended, needs its own scoped identity, reaches real data and real money, and keeps running long after anyone is watching it directly. Design deliberately for identity, tools, network and data, cost and time, and visibility before it ships.
Why does an agent need its own identity rather than reusing a developer's credentials?
Access, logs and revocation all attach to an identity. If an agent shares a person's credentials, disabling the agent also disables that person, and its actions are indistinguishable from theirs in any audit trail. A distinct service identity can be scoped, monitored and revoked on its own, without affecting anyone else.
What is a never-list, and how does it differ from a permission list?
A permission list states what an agent can technically reach. A never-list states which of those reachable actions it must never carry out alone, enforced in the tool's own code rather than only written in a prompt instruction. An agent can hold broad read access and still be blocked, in code, from a specific destructive action.
Why did the same resource holding both live data and its backup matter in the incident described in chapter 1?
When backups live inside the same resource as the live data, one destructive action can remove both at once, however narrow the agent's tool scope is otherwise. Genuine isolation, a different identity and ideally a different resource for backups, means a single failure cannot take out the only recoverable copy alongside the original.
Name the four controls that together stop a runaway agent loop.
A per-call timeout stops a single step running indefinitely. A per-session budget caps total calls, tokens or spend. A wider daily budget catches what a session limit alone might miss. A circuit breaker is the mechanism that actually ends the session once a limit is crossed, rather than only logging that it happened.
What should never appear in plain form in an agent's logs?
Secrets and credentials, full payment details, and any other data your organisation classifies as sensitive, such as health information. Redact these before a log line is written, not in a later clean-up pass, because by the time a clean-up runs the value may already sit in backups or a monitoring tool.
Why does a release-gate evaluation set need adversarial cases, not just ordinary ones?
Ordinary cases mostly test the happy path, the part of an agent's behaviour least likely to have broken. Adversarial cases, hidden instructions, edge-of-remit requests, ambiguous phrasing, deliberately probe for the failures that matter most when they occur, even though they are rare in normal traffic. A gate without them mainly confirms what already worked.
How is drift different from an outright bug?
A bug usually fails loudly and traces back to a code change. Drift is a live agent's behaviour changing because the model, an upstream API or the data it reads changed, without its own code changing at all. It is quieter, easy to miss, and can persist for weeks before anyone notices.
Why review a dependency even when an agent's own code has not changed?
The model provider, tool APIs and libraries an agent relies on can change their behaviour, response format or terms independently of the agent's own release process. A scheduled review, actually reading changelogs rather than only bumping version numbers, catches a change before it causes a silent failure or a drift nobody has explained yet.
What does this course's incident-recovery exercise prove, and what does it not prove?
It proves a team can work through a runbook honestly, on an invented fixture, and surface real gaps in the plan itself. It does not prove the same team would perform equally well under real pressure, and it is not a substitute for a genuine security assessment carried out by qualified professionals against a live environment.
What is the first step when a tool credential is suspected compromised?
Contain first: revoke or rotate the specific credential immediately, so it stops working within minutes, and lower the relevant approval threshold to zero if needed. Investigating how it leaked comes after containment, not before, because every minute a suspected credential stays valid is a minute it can still be misused.
Does completing this course mean an organisation meets ISO/IEC 27001 or ISO/IEC 42001?
No. Those are paid standards setting requirements for an information security management system and an AI management system. Meeting either needs a real audit against the standard's own text by a qualified party. This course's production-readiness dossier is informed by similar ideas but is not equivalent to, and does not claim to be, that audit.
Write as you go
My notes
Use this scratchpad for your own notes, working or answers as you read. Notes are saved in this browser on this device. Downloading makes a local copy; it does not send your notes to Mickai.
Learn → Practise → Demonstrate
Ready to put it into practice?
Take the scored exam when you feel ready. You do not need to download the workbook first. A score strictly above 80% earns a named, dated Mickai certificate with a verification page.
Take the official examYour name and email are collected at exam start. Certificates record an assessment result, not an accredited qualification or verified identity.
Learn the language
Key terms
- Service identity
- A distinct identity issued to an agent itself, separate from any human user's credentials, so its access can be scoped, logged and revoked on its own.
- Least privilege
- Giving an agent only the smallest set of permissions its actual task needs, nothing kept just in case it might be useful later.
- Never-list
- A written list of actions an agent must never take without a person approving, enforced in the tool's own code, even where it technically has the access to take them.
- Blast radius
- The extent of damage a single failure, bug or compromised credential can cause, because of what it can reach.
- Egress control
- A rule restricting which external systems or addresses a running agent's network traffic may reach.
- Circuit breaker
- A control that ends an agent's session automatically once a defined limit, such as cost, calls, time or errors, is crossed.
6 of the workbook's 12 terms. The complete glossary is in the workbook.
Follow the evidence
Sources and checks
Facts last checked: .
Examples in this workbook were run on: Concepts and worked examples reviewed against publicly documented incident write-ups and standards pages; no code in this course was executed, as none is required to complete it (2026-09-29).
These workbooks use AI assistance. See how the workbooks are made.
- AI Risk Management Framework (page noting AI RMF 1.0 is being revised; read 29 September 2026)National Institute of Standards and Technology (NIST)
- Artificial Intelligence Risk Management Framework (AI RMF 1.0), NIST AI 100-1 (January 2023)National Institute of Standards and Technology (NIST)
- ISO/IEC 27001:2022 Information security, cybersecurity and privacy protection, Information security management systems (read 29 September 2026)International Organization for Standardization (ISO)
- ISO/IEC 27001:2022/Amd 1:2024 (climate action amendment; read 29 September 2026)International Organization for Standardization (ISO)
- ISO/IEC 42001:2023 Information technology, Artificial intelligence, Management system (public description only; read 29 September 2026)International Organization for Standardization (ISO)
- ai-agents-for-beginners (repository; read 29 September 2026)Microsoft
- ai-agents-for-beginners LICENSE (MIT; read 29 September 2026)Microsoft
- AI agent destroys production database in nine seconds: a PocketOS case study (read 29 September 2026)Zenity
- 5 lessons from the 9-second AI agent that deleted a production database (read 29 September 2026)Mondoo
Created by Mickarle Wagstaff-Irons - Micky Irons with the Mickai team. Published by Mickai LTD. Last updated 29 September 2026.
NextKeep going
Where to go next
Recommended for you
Deploy AI agents without losing control
Plan least-privilege access, prohibitions, approval thresholds and a checked log for AI agents. Exercises distinguish written plans from implemented controls.
Recommended for you
Threat-model an agent and its tool boundary
Map an agent tool boundary and test a local gateway for identity, ownership, exact-action approval, expiry, replay and stale writes using fictional notes.
Recommended for you
Testing agent loops: budgets, termination and failure recovery
Test an agent loop locally: enforce budgets, replay model decisions, reject late results and verify bounded retries without paying for model calls.