Lesson 7.2: Guardrails, permissions and human approval
Learn how to limit an agent: guardrails, permissions and budgets in tools, the trade-off between missed harm and false blocks, and a safety specification.
By the end of this lesson you will be able to name the places where an agent can be limited, tell controls that enforce from controls that only ask, design a guardrail with its two kinds of error in mind, set permissions and budgets in the tools, and write a short safety specification for an agent. You will work out that a guardrail that catches 90 per cent of harmful requests and wrongly blocks 2 per cent of harmless ones, on 10,000 requests a day with 0.5 per cent harmful, blocks 45 harmful and 199 harmless requests and so is right in only 18 per cent of its blocks, and why that is still sometimes a good trade. You should have read Lessons 6.1, 6.3 and 7.1. No code is needed. The mathematics is percentages and a ratio.
Lesson 7.1 measured what an agent does. This lesson is about limiting what it can do. A guardrail is any control that keeps an agent's behaviour within safe bounds. The word covers a wide range, from a sentence in the instructions to a lock in the database, and the first distinction to learn is how much weight each can bear. A guardrail that the model can talk its way around is a request. A guardrail that the model cannot bypass is a control. Real safety rests on controls, with requests used only as an extra layer.
Requests and controls
Imagine you do not want an agent to send money to new payees without approval. Compare three ways to say so.
Instruction. The system prompt says, "Never pay a new payee without approval."
Check on the output. A second model reads the proposed payment and flags it if the payee is new.
Enforcement in the tool. The payment tool refuses any payee not on the approved list unless it is given an approval token created by a person.
All three are useful, but they differ greatly in strength. The instruction relies on the model following it, which it usually does and sometimes does not, especially under pressure from adversarial text. The model check is better but can be fooled or can make mistakes. The tool enforcement does not depend on the model at all. Even a fully compromised agent cannot pay a new payee, because the tool will not let it.
This gives a rule of design: put the important limits where the model cannot undo them. Use instructions to shape ordinary behaviour, checks to catch mistakes and tools to enforce the rules that matter. When someone asks "how do we stop the agent doing X?", the first answer should be "make X impossible", and only the second "tell it not to".
Where guardrails go
An agent's run has several points where a limit can be applied. Think of them as layers.
Layer · Where · What it limits · ExampleInput · Before the model sees a request · What the agent is asked to deal with · Reject requests in a banned category. Remove card numbers
Instructions · In the system prompt · Ordinary behaviour, tone, scope · "Only answer questions about our products"
Tool access · In which tools it is given · What it can do at all · A support agent has no deletion tool
Tool enforcement · Inside each tool · What each action may do · Refund limit, approved payees, read-only database role
Output · Before a reply or action leaves · What the agent may say or send · Block replies that include another customer's data
Run limits · Around the whole run · Steps, time, cost, repeats · At most 15 steps and ₹10 per run
Human approval · At chosen actions · The most costly or irreversible steps · Supervisor approves refunds over ₹5,000
Monitoring · After the fact · What actually happened · Alerts and review of samples
No single layer is enough. Each fails sometimes. A design with several layers, each catching some of what the others miss, is far safer than one that depends on a single wall. And the layers that matter most are the ones in the tools.
Permissions: the strongest layer
The strongest limit is the power the agent never had. Four rules apply.
Least privilege. Give each agent only the tools and access its job needs. A reporting agent gets a read-only database role. If it is compromised or confused, it can read but not change.
Narrow tools. A tool that does exactly one thing is safer than a general one. A refundorder(orderid, amount) tool with a limit is safer than a tool that runs any SQL.
Separate identities. Run each agent as its own identity with its own permissions, not as a shared superuser. Then you can see what each did and revoke one without affecting others.
Limits on the action's size. Put numeric limits in the tool: a refund cap per order and per day, a maximum number of emails per hour, a maximum number of rows a query may return. A runaway agent then hits a wall.
Budgets and run limits
Every agent should have limits on a run: a maximum number of steps, a maximum time, a maximum token or money budget and a maximum number of repeats of the same call. When a limit is hit, the run stops and hands back, as Lesson 6.3 described. These limits cost almost nothing and protect against many failures, from loops to runaway spend, which Lesson 7.4 covers. Set them from data: look at how many steps a normal run takes, and set the cap at a comfortable margin above, say twice the 95th percentile.
Approval
Lesson 6.3 covered human approval in detail. In the layers above it is the control for the few actions where a mistake would be costly or irreversible, and where a person's judgment adds something. Enforce it in the tool, tie it to the exact action, and keep the number of requests small enough that people read them.
Guardrails on inputs and outputs
Some guardrails inspect text rather than limit actions. They look at what comes in and what goes out. Examples include:
detecting requests that are off topic, abusive or harmful
detecting attempts to manipulate the agent, as Lesson 7.3 describes
finding personal data such as card or ID numbers and removing it
checking an output for another person's data, unsafe advice, a claim the sources do not support or a leaked secret
checking the format, for example that a reply is valid and complete before it is sent
These checks can be done by simple rules, such as patterns for card numbers, by a trained classifier, or by a model reading the text. Rules are fast and exact but narrow. Classifiers and models are broad but make mistakes. Most systems use a mix.
The two kinds of error
Any check that decides "allow or block" can be wrong in two ways.
A miss, when it allows something harmful. The harm happens.
A false block, when it blocks something harmless. A legitimate user is refused, annoyed, or delayed.
These are traded against each other. A stricter check misses less and blocks more harmless things. A looser one blocks fewer harmless things and misses more harm. You cannot reduce both to zero. The right balance depends on the cost of each kind of error, and it differs by case: for a check against leaking another customer's data, a miss is serious and a false block is a nuisance, so you accept many false blocks. For a check on tone, a miss is minor and a false block interrupts good work, so you accept some misses.
Why the numbers surprise people
Harmful requests are usually rare. This makes even a good guardrail produce mostly false alarms. Take a daily load of 10,000 requests, of which 0.5 per cent, 50 requests, are harmful. The guardrail catches 90 per cent of harmful requests, and wrongly blocks 2 per cent of harmless ones.
Harmful requests caught: 50 × 0.90 = 45.
Harmful requests missed: 5.
Harmless requests: 9,950. Wrongly blocked: 9,950 × 0.02 = 199.
Total blocked: 45 + 199 = 244. Of these, 45 were right, so only 45 ÷ 244 = 18.4 per cent of blocks were correct.
So four out of five blocks are mistakes, though the guardrail seems accurate by both of its own measures, 90 per cent caught and 98 per cent of harmless requests passed. This is a standard result when the thing you hunt is rare, and it is why measuring a guardrail by its catch rate alone is misleading.
Predict first: 10,000 requests a day, 0.5 per cent harmful. A guardrail catches 90 per cent of harmful requests and wrongly blocks 2 per cent of harmless ones. Of the requests it blocks, roughly what share are actually harmful? Make a guess before you read the answer.
The answer is about 18 per cent. Whether that is acceptable depends on what a miss costs and what a false block costs. If each missed harmful request costs ₹50,000 and each false block costs ₹20 in delay and complaints, then catching 45 harmful requests avoids ₹22,50,000, and the 199 false blocks cost ₹3,980, so the guardrail is plainly worth it. If a miss costs ₹100 and a false block costs ₹50, the guardrail costs more than it saves. The numbers decide, not the instinct that more blocking is safer.
The share of correct blocks depends heavily on how rare harm is. With the same 90 per cent catch rate and 2 per cent false-block rate, it is 4.3 per cent when 0.1 per cent of traffic is harmful, 18.4 per cent at 0.5 per cent, 47.9 per cent at 2 per cent and 83.3 per cent at 10 per cent. The same guardrail is a poor filter on mostly harmless traffic and an excellent one on mostly harmful traffic. Always judge it against the traffic it will really see.
Making false blocks cheaper
You can cut the cost of a false block without loosening the guardrail. Give a blocked user a clear, polite message and a way to ask for a review. Send borderline cases to a person rather than refusing outright. Use a cheap, fast check first and an expensive, accurate one only on what the first flags, so that most harmless requests pass quickly. And log every block, so that you can sample them, find the pattern in the false ones and fix it.
Output checks and the actions that matter
For text going to a person, an output check can catch an unsafe or wrong reply before it is sent. For actions, the equivalent is a check in the tool: does the action fit the rules? Where the rule is exact, such as a refund cap, use code. Where it needs judgment, such as "is this reply appropriate for a distressed customer?", use a model check or a person, and accept that it will sometimes be wrong.
Be careful of one trap: a check performed by the same model, in the same context, that produced the output. It tends to agree with itself. Use a separate call with a different prompt, or a different model, and give it only what it needs to judge.
A safety specification
Before building an agent, write a one-page safety specification. It forces you to decide the limits deliberately and gives testers and reviewers something to check. It has seven parts.
1. Purpose and scope. What the agent is for and what it must never be used for.
2. Assets at risk. What could be harmed: money, personal data, systems, reputation, people.
3. Allowed actions. Each tool, with its permissions, limits and whether it reads or writes.
4. Forbidden actions. What must never happen, and where each is prevented, in a tool, a check or an instruction.
5. Approval rules. Which actions need a person, who approves and the evidence shown.
6. Run limits. Steps, time, cost and repeats, and what happens when one is reached.
7. Monitoring and response. What is logged and alerted, who responds and how to stop the agent quickly.
For each forbidden action, the specification should say which layer enforces it. If the answer is "the instructions", the control is weak, and you should consider moving it to a tool.
Testing guardrails
A guardrail you have not tested is a guess. Test in three ways.
Normal use. Run the evaluation suite from Lesson 7.1 and check that guardrails do not block legitimate work. Measure the false-block rate on real traffic.
Attack. Try to get around each guardrail. Ask the agent to do the forbidden thing directly, then indirectly, then with a story, then by claiming authority, then through a document it reads. A security reviewer or a red team does this best, and the attempts become new test tasks.
Failure. Switch off a layer and see what the next one does. If the instruction is ignored, does the tool still stop the action? If the tool fails, does the output check catch it? The aim is to know how many layers stand between a mistake and harm.
Re-run these tests whenever tools, instructions or models change.
Three worked examples
Example 1: a payments agent
An agent prepares supplier payments. It has a tool to read invoices and a tool to propose payments. The propose tool writes to a queue and cannot move money. A separate release step, run by code after a person approves, makes the payment. The tool enforces: payees must be on the approved list, each payment is under ₹10 lakh, and total proposals per day are under ₹1 crore. A new payee needs a procurement approval first. The instructions repeat the rules, but nothing depends on them. In red-team testing, the agent is told by an injected invoice note to pay a new account, and the tool refuses. The layers held, and the instruction was the weakest of them.
Example 2: a customer reply guardrail
A support agent drafts replies. An output check, with a separate model call and a short rubric, looks for four problems: another customer's data, a promise of something outside policy, an insult and a missing refund figure when one applies. On 5,000 replies a day, about 1 per cent have a real problem. The check catches 85 per cent, and wrongly flags 3 per cent of good replies. That is 42 caught, 8 missed and 148 false flags, so about a fifth of flags are correct. Flagged replies go to a person for a quick review instead of being blocked, so a false flag costs a minute. The team judges that the 8 misses a day, mostly minor, are acceptable and tracks them by sampling.
Example 3: guardrails that were only instructions
A company's data agent was told in its prompt to "never run queries that change data". It was connected with a database account that had full write access. A user asked it to "clean up duplicate rows", and it ran a delete. The instruction was clear, and the model decided that the user's request took priority. The fix took ten minutes: the agent's database role was changed to read-only. The model did not misbehave in any unusual way. The control was in the wrong place.
A checklist for guardrails
1. List the harms you must prevent and the assets at risk.
2. For each, choose where it is prevented. Prefer tools and permissions.
3. Apply least privilege: narrow tools, a separate identity and read-only wherever possible.
4. Put numeric limits in tools: sizes, counts, rates and daily totals.
5. Set run limits for steps, time, cost and repeats, from real data.
6. Add input and output checks where they help. Measure misses and false blocks, and weigh them by cost.
7. Make false blocks cheap: clear messages, a review route and a fast first-stage check.
8. Use a separate call or model for judging outputs.
9. Write the safety specification and name the layer for every forbidden action.
10. Test normal use, attacks and layer failure, and repeat after every change.
Common mistakes
Safety in the prompt only. The model can be talked out of it.
One layer. Each layer fails sometimes. Use several.
A powerful shared account. Give each agent its own narrow identity.
General tools. A tool that runs any query or command has no limit.
Judging a guardrail by its catch rate. When harm is rare, most blocks are false alarms.
Ignoring the cost of false blocks. Users get refused, and may stop using the agent.
Self-checking in the same context. The model tends to agree with itself.
No run limits. Loops and runaway cost go unchecked.
Never attacking your own guardrails. Someone else will.
Not retesting after changes. A new model or tool can undo a control.
Key takeaways
Separate requests from controls. A limit the model can bypass is a request. Put important limits in the tools, where the model cannot undo them.
An agent has layers where it can be limited: input, instructions, tool access, tool enforcement, output, run limits, human approval and monitoring. Use several.
Permissions are the strongest layer: least privilege, narrow tools, separate identities and numeric limits in tools.
Every allow-or-block check has two errors, misses and false blocks. When harm is rare, most blocks are false alarms: a 90 per cent catch rate and a 2 per cent false-block rate give only 18.4 per cent correct blocks on 0.5 per cent harmful traffic.
Decide by cost: compare the value of the harm prevented with the cost of false blocks, and make false blocks cheap to release.
Write a one-page safety specification and name the layer that enforces each forbidden action.
Test normal use, attacks and layer failure, and repeat after every change.
Check yourself
1. What is the difference between a request and a control?
A request, such as an instruction, depends on the model following it. A control, such as a permission in a tool, works whatever the model does.
2. Name four of the layers where an agent can be limited.
Any four of: input, instructions, tool access, tool enforcement, output, run limits, human approval and monitoring.
3. 20,000 requests a day, 1 per cent harmful. A guardrail catches 80 per cent of harmful ones and wrongly blocks 1 per cent of harmless ones. How many harmful requests does it catch, and how many harmless ones does it block?
Harmful: 200, caught 160. Harmless: 19,800, blocked 198.
4. In that case, what share of blocks are correct?
160 ÷ (160 + 198) = 160 ÷ 358 = 0.447, about 44.7 per cent.
5. Why is it risky to have the same model, in the same context, check its own output?
It tends to agree with itself. A separate call, a different prompt or a different model gives a more independent check.
6. Why should a refund cap be in the tool and not only in the instructions?
The model could ignore or be talked out of an instruction, but it cannot get past a tool that refuses refunds above the cap.
Try this
Set aside seventy-five minutes.
1. Write the safety specification for an agent you are building or imagining, with all seven parts.
2. For each forbidden action, name the layer that enforces it. Move any that rest only on the instructions into a tool or a permission.
3. List the tools and give each the narrowest permission and a numeric limit.
4. Set run limits: steps, time, cost and repeats, from realistic run data.
5. Choose one input or output check. Use the simulator with your estimated traffic and costs to see misses, false blocks and value.
6. Write ten attacks against your guardrails and the result you expect from each.
7. Decide how you will switch the agent off quickly if something goes wrong.
A good result is a one-page safety specification, a table of tools with permissions and limits, and a list of attack tests. Lesson 7.3 looks closely at the most common attack on agents: instructions hidden in the content they read.
Tags: Agentic AI Guardrails Permissions Agent safety Risk controls