# AI Agent Guardrails: Controls That Hold | QQuantum.ai

> AI agent guardrails that hold: input filters, output checks and action-side limits for LLM systems, what a classifier can catch, and how to refuse a user well.

Source: https://qquantum.ai/technology/guardrails

[Home](https://qquantum.ai) [technology](https://qquantum.ai/technology) guardrails

Technology

# AI guardrails: a control, not a product.

AI agent guardrails are the controls around an LLM system: filtering what goes in, checking what comes out, and constraining what the agent is able to do. Only the third is deterministic, and it is the one teams reach for last. This page is for teams putting agents near real data or actions; it covers each layer, its limits and escalation to a person.

- Input · output · action
- Escalation design included

All Technology & Model Stack →

Introduction transcript. Qubi: A rule written into a prompt can be talked around by the wrong text. We screen what goes in and check what comes out, and we measure both. The action gate holds: narrow permissions, spending caps, and a person confirming what matters. Every action is logged with its arguments, so the worst case stays small.

## The word is doing too much work

Ask three teams what guardrails they have and you get three unrelated answers: a paragraph in the system prompt, a toxicity classifier, a human approval step before anything is sent. All three are guardrails. Only one of them survives a determined adversary, and it is not the paragraph.

It helps to drop the word and describe the control precisely: what it inspects, what it does when it fires, whether it fails open or closed, and who finds out. A control described that way can be tested and audited. “We have guardrails” cannot, which is why it appears so often in vendor material and so rarely in an architecture review.

The underlying position on this page is simple. Content controls reduce the rate of bad outputs; they do not bound the damage of one. Only the action layer bounds damage, because it is the only layer where the answer to “what is the worst this system can do?” is enforced by something other than a model's judgement.

WHERE A CONTROL CAN SIT

1. 01 Input user, document, tool result
2. 02 Input checks policy · PII · heuristics
3. 03 Model reasoning + tool proposal
4. 04 Output checks grounding · schema · leaks
5. 05 · Branch / escalation Escalate typed refusal or a human
6. 06 Action gate scope · confirm · caps
7. 07 Effect logged with its arguments

Lower box = a fired control and where it goesMarker = one request through the system

Four surfaces, and they are not interchangeable. A weakness at the action gate cannot be compensated for by adding another classifier at the input, though that is the usual response because it is the cheaper change.

## Input side

01

### Topic and policy classification

A cheap classifier deciding whether a request is in scope at all, before the expensive model sees it. Genuinely useful for a narrow assistant — a support agent has no business answering medical questions — and it doubles as a cost control, since an out-of-scope request rejected for a fraction of a cent never reaches the model. The failure mode is a boundary drawn tighter than the business wants, which shows up as a refusal rate nobody is watching.

02

### PII detection and redaction

Detecting personal data at the prompt boundary and replacing it with a token before anything leaves your perimeter, then re-inserting the real value in the response. Effective for structured identifiers — card numbers, national insurance numbers, account references — where pattern matching is reliable. Much weaker on free-text identifiers, since a name in a sentence is a name only in context, and a detector tuned to catch every one of them will also redact half your product catalogue.

03

### Injection heuristics, and their ceiling

Scanning input for instruction-like text catches the obvious attempts and creates a false sense of coverage. There is no reliable way to distinguish an instruction from a description of an instruction, and the attack surface includes any text the model reads — retrieved documents, tool results, an email body, the alt text on an image. Worth having as one signal among several. Never worth relying on. The structural answer is on our [prompt injection](https://qquantum.ai/resources/prompt-injection) page, and it is about privilege rather than detection.

04

### Identity, rate and cost limits

The least glamorous input control and the one that behaves most predictably: who is asking, how often they may ask, and what a single conversation is allowed to spend. These are ordinary application controls rather than AI ones, they fail closed, and they bound both an abuse case and a runaway loop with the same mechanism.

## Output side

01

### Grounding and citation checks

The highest-value output control in a retrieval system, and a mechanical one: does every factual claim in the answer appear in the passages that were retrieved? Where the answer cites a span, the span can be checked against the source text directly. Where it does not, a second model can be asked the narrow question — is this sentence supported by this passage — which is a far more reliable judgement than asking whether an answer is good.

02

### Schema and type validation

Deterministic, cheap, and frequently the only guardrail a pipeline needs. If the output must be an object with a known shape, validate it and reject what does not conform. Constrained decoding handles most of this at generation time; validation afterwards still earns its place because it is where business rules live — the identifier exists, the amount is within range, the date is not in the future.

03

### Policy classification on the way out

Checking a response against the rules the business actually has: no advice in a regulated category, no commitment to a discount, no statement about a competitor. This is usually where a generic safety classifier disappoints, because the rules that matter to a bank are not the rules a general model was tuned for. Written policies converted into concrete, checkable criteria outperform a holistic quality prompt by a wide margin.

04

### Leak checks

Scanning the outbound response for material that should not be in it: the system prompt, another tenant's data, a credential, an internal hostname, personal data that was redacted on the way in. Cheap to implement as pattern matching against known-sensitive strings, and worth doing precisely because the failures it catches are the ones that become incidents rather than complaints.

## Action side, which is the one that holds

Everything above is probabilistic. The action layer is not, and that asymmetry should decide where the effort goes. A content filter reduces how often the system says something it should not. A permission boundary determines what the system can do when every content filter has already been defeated — which is the case you are actually designing for.

Least privilege on tools. Read-only by default. A separate, narrower credential per tool rather than one service account with broad rights. Scopes that match the task and not the convenience of whoever wired it up. An agent that can only read cannot be talked into writing, no matter what appears in a retrieved document.

Act as the user, not as the service. Authorisation should be evaluated against the permissions of the person whose request triggered the action, so an agent working on behalf of a junior employee cannot reach what that employee cannot reach. This is the single control that most reliably contains an injection, and it is architectural work rather than model work.

Confirmation for consequential actions. Not for everything, which trains people to click through; for the small set that is irreversible or externally visible. Sending an email, moving money, deleting a record, publishing anything. The confirmation must show the actual arguments — a dialogue that says “approve this action?” without showing the payload is theatre.

Caps, budgets and blast radius. A maximum number of tool calls per conversation, a spend ceiling, a limit on how many records a single run may touch, a rate limit on outbound messages. These bound the worst case arithmetically, which is a different kind of assurance from a classifier's accuracy figure, and they are what makes an incident recoverable rather than large.

Reversibility and a real audit trail. Prefer designs where an action can be undone: a draft rather than a send, a proposed change rather than an applied one, a soft delete. And log the arguments, the identity, the retrieved context and the decision path — not only the outcome. Reconstructing why a system did something is the question every post-incident review asks, and a log of outputs alone cannot answer it.

## The three places a rule can live

Compare your options

| Criterion | In the prompt | In a classifier | In the architecture |
| --- | --- | --- | --- |
| Holds against a determined adversary | No | Sometimes | Yes, within its scope |
| Deterministic | No | No | Yes |
| Added latency | Tokens only | A model call, or a parallel one | Negligible |
| Added cost per request | Low | Real, and per request | Near zero |
| Testable | Against an eval set | Precision and recall on labelled data | As ordinary code |
| Evidence for an auditor | The prompt text | A score distribution | A permission model and a log |
| Failure mode | Silently ignored | False positives and negatives | Blocks legitimate work |
| What it is genuinely good at | Tone, format, default behaviour | Volume triage and routing | Bounding the worst case |

## A classifier in front of a model is another model

This is the point most guardrail discussions skip. A safety classifier has a false positive rate and a false negative rate, it can itself be manipulated by the text it is reading, and it has to be evaluated and monitored exactly like the system it protects. Adding one does not remove uncertainty from the system; it moves some of it and adds a component.

Base rates decide whether it is worth it. If one request in ten thousand is genuinely a problem, a classifier at 95% precision still floods the review queue with false positives, and the people staffing that queue stop reading carefully within a fortnight. The useful question is never the accuracy figure on its own; it is how many alerts a day the deployment produces and whether anyone can act on that number.

Pick the direction deliberately. Every threshold is a choice between blocking legitimate work and letting something through, and the right side of it differs by application. A public-facing assistant should probably fail closed; an internal research tool that refuses a fifth of its queries will be routed around by its users, which is a worse security outcome than the one you were preventing.

They can be attacked too. Input that reads innocuously to a classifier and carries an instruction to the main model is a known technique, and so is padding an input past the classifier's own context limit. Treat a guardrail model as part of the attack surface, keep it updated, and never let its verdict be the only thing standing between a request and a consequential action.

None of this argues against classifiers. It argues for measuring them: precision and recall on labelled data drawn from your own traffic, tracked over time, re-checked whenever either model changes. A guardrail nobody has measured is a belief, and beliefs are what incidents are made of.

## Refusing well matters more than refusing often

What happens when a control fires is designed far less often than the control itself, and it is where users form their opinion of the system. A blank refusal with no reason teaches people that the tool is unreliable, and they take their question somewhere with no controls at all — a personal account, a consumer chatbot, a colleague. Shadow usage is the direct product of a badly designed refusal.

A refusal worth shipping does four things: it says what it will not do and, where it can, why; it offers the route that does work, including a human one; it preserves what the person already typed so they are not starting again; and it records the event with enough context that someone can review whether the boundary is in the right place. The fourth is what converts refusals from an irritation into evidence — a weekly look at what fired, and how much of it was wrong, is how a policy gets tuned rather than argued about.

Escalation is the other half. A control that fires should have a defined destination: a typed error the model can recover from, a queue a human owns, a support handover carrying the full context, or a hard stop with a reference the user can quote. “The request was blocked” with no destination is not a control, it is a dead end, and it is the version most systems ship.

Questions

## Questions about AI Guardrails.

### Should we buy a guardrails product?

For content moderation at volume, a hosted classifier is a reasonable buy and cheaper than building one. What cannot be bought is the part that matters most: the permission model, the tool scopes, the confirmation steps and the audit trail are specific to your systems and your authorisation logic. A product can tell you a response looks unsafe; it cannot tell you this user is not allowed to refund that order. Buy the commodity layer if it helps and build the action layer regardless.

### How much latency do guardrails add?

Input classification and output checks each add a model call, so a naive implementation can double perceived latency. Most of it is recoverable: run independent checks in parallel rather than in series, use a small fast model for triage and reserve the larger one for the ambiguous middle, stream the response while the output check runs and retract if it fires, and skip checks that cannot apply to the request type. Architectural controls add essentially nothing, which is another argument for putting the weight there.

### Can the model be its own guardrail?

Partly, and it is worth doing because it is nearly free — asking a model to check its own output against explicit criteria catches real errors. It is not independent, though: a model that was talked into a bad answer is quite likely to approve it, and self-review shares the failure modes of the generation it is reviewing. Use it as a cheap first pass, not as the control you would describe to a regulator.

### What do we tell an auditor we have?

Describe the controls concretely rather than by category: the tool scopes and what each credential can reach, which actions require confirmation and who confirmed them, the caps in force, what is logged and for how long, the eval set that gates deploys, and the review process for what the controls block. That is a stronger position than a list of filters, and it is the version that holds up when someone asks what happens if a filter is wrong. We hold no security certifications, and we say so plainly on the trust pages; what we bring is the design and the evidence trail your own audit can use.

### Do guardrails stop prompt injection?

They reduce the rate of the obvious attempts and do not close the problem. Injection is not solved, and detection is the weakest of the available responses because there is no reliable signal separating an instruction from text describing one. What genuinely limits the damage is the action layer: least privilege, per-user authorisation, confirmation on consequential steps, and a blast radius small enough that a successful injection is a nuisance rather than an incident.

Keep reading

- [Resource Prompt Injection Explained](https://qquantum.ai/resources/prompt-injection)
- [Technology Evaluating AI Systems](https://qquantum.ai/technology/ai-evals)
- [Trust Security Architecture](https://qquantum.ai/trust/security)
