Skip to content
mentoor

Topic 4 of 5 · 5 min read

Layering guardrails with tool limits and approvals

Goal: Design a layered plan for an agent feature and state which risk each layer reduces.

A guardrail filters what a model reads and writes; it cannot stop a model from doing something it has the power to do, so the damage limit has to come from layers around the model. Assume each layer will sometimes fail and make sure no single failure is a disaster.

Check yourself · 1 of 3

An agent has a read-only database role and no network access. A prompt injection gets through the classifier. What limits the damage?

Choose one answer

Why it matters

Researchers have shown that automatically generated text suffixes can push aligned models past their safety training, and injection classifiers miss paraphrased attacks. A filter that catches most attacks still lets the rest through. Once an agent can send email, run code or spend money, "most" is not enough. Simon Willison's "lethal trifecta" names the dangerous combination: access to private data, exposure to untrusted content and a way to send data out. If all three are present, a filter alone is not a defence.

The layers

  1. Least privilege. Give the agent tools scoped to the task: read-only database role, one folder, one mailbox. Reduces the damage of any bad action.
  2. Remove a leg of the trifecta. No outbound network, or no private data in the same session as untrusted content. Reduces data theft structurally.
  3. Sandboxing. Run code in a container with no secrets, no network and a time limit. Reduces what generated code can touch.
  4. Rate and spend limits. Cap calls, tool uses and cost per user and per run. Reduces runaway loops and abuse.
  5. Human approval. Require a person to confirm irreversible or external actions such as sending, paying and deleting, showing exactly what will happen. Reduces the actions that cannot be undone.
  6. Guardrails. Input and output classifiers. Reduce the volume of attacks and unsafe text that reach the other layers.
  7. Logging and alerts. Trace every tool call so a failure is found.

Before and after

Before: a support agent with write access to the whole customer database and an email tool, protected by an injection classifier. After: it reads one customer's record through a scoped role, drafts replies that a human sends, cannot call external URLs, and is limited to 20 tool calls per ticket.

What goes wrong

  • Treating the classifier as the security boundary.
  • Approval fatigue. If people click yes on every prompt, the layer is gone. Ask only for the actions that matter and show the real effect.
  • Layers sharing one weakness, such as every check reading the same unsanitised text.

Examples

A layered plan for a refund agent

Layer Setting Risk reduced
Least privilege Read one order; refund tool capped at 50 per call Mass refunds
Network No outbound requests Data exfiltration
Approval Human confirms any refund above 20 Wrong or tricked refunds
Rate limit 10 tool calls per ticket Loops, abuse
Guardrails Injection check on customer text Cheap, common attacks

A confirm step that shows the effect

The agent wants to:
  Send email to dana@northwind.example
  Subject: Refund of 42.00 approved
  Attach: invoice-1187.pdf
[Send]  [Edit]  [Cancel]

The person sees the recipient, text and attachment, not just "Allow tool call?"

Key points

  • A guardrail filters text; it does not remove the power to act, so limits must come from other layers.
  • Least privilege and removing one leg of the lethal trifecta reduce damage structurally.
  • Sandboxes, rate limits and spend caps contain generated code and runaway loops.
  • Human approval belongs on irreversible or external actions and must show the exact effect.
  • Each layer should be named with the risk it reduces, because every layer will sometimes fail.

Common mistakes

  • Treating one injection classifier as the whole security boundary.
  • Asking for approval on every small step until reviewers click through without reading.
  • Giving the agent a broad admin credential for convenience.
  • Building several layers that all depend on the same unchecked input.

Check yourself · 2 of 3

Which action is the best candidate for human approval in an email agent?

Choose one answer

Check yourself · 3 of 3

Why does the lethal trifecta make a classifier alone a weak defence?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic