Blog

What are AI guardrails?

10 min read

The short answer

Guardrails are the constraints that keep an AI system inside the boundary you defined, enforced by engineering rather than by asking the model nicely. They decide what it can see, what it can call, what it can say, and what it can do.

The useful test is whether the constraint still holds when the model misbehaves. If your protection is a sentence in the prompt, it does not hold, because the model is the thing you are protecting against.

This is the layer that separates a demo from something you can put in front of customers, and it is the layer that gets built last, usually after an incident.

A good prompt is not a guardrail

Almost every team starts by writing instructions: never reveal internal data, always refuse off topic questions, stay professional. These help. They are not controls.

A prompt is a request to a probabilistic system. It works most of the time, which is the worst possible property for a security boundary, because most of the time is exactly how you get an incident that nobody can reproduce.

The distinction is simple. A prompt says what the model should do. A guardrail makes the alternative impossible. If a user cannot access a record through your API, no phrasing should let them access it through your assistant.

The four layers

Input. What reaches the model at all: length limits, content filtering, stripping or escaping anything from an untrusted source, and rejecting requests that have no business being made.

Scope and permission. What the system is allowed to see and call for this specific user, enforced at the data layer.

Output. What is allowed to leave: format validation, grounding checks against the source, filters for data that should never appear in a response.

Action. What it can actually do to your systems: which functions, with what limits, idempotent where writes are involved, and what requires a human before it executes.

Permissions are the layer that actually matters

If you only build one, build this one. The most common serious failure in production AI is not an offensive answer, it is a system that surfaces data the person asking was never entitled to see.

It happens because retrieval and permissions get built separately. The index is populated once with everything, and the filtering is expected to happen later, in the prompt or in the interface. Then a question arrives phrased in a way nobody anticipated, and the document comes back.

The fix is unglamorous: carry the requesting user's identity all the way through, filter at query time rather than after, and never let a service account with broad rights be the thing making the call. This is also why MCP servers need scoping, and why vector databases need permission metadata attached at ingestion rather than bolted on.

Output guardrails and what they cannot catch

Output checks catch structural problems well: wrong format, missing required fields, text that looks like a credit card or a document number, answers that cite nothing when they were supposed to cite a source.

Grounding checks are the valuable ones. You verify that what the model said is actually supported by the passages it was given, rather than assembled from training data. In a regulated setting this is often the difference between an answer you can defend and one you cannot.

What output checks cannot catch is a confident, well formatted, plausible answer that happens to be wrong in a way only a domain expert would notice. That is not a guardrail problem, it is an evaluation problem, and the two get confused constantly.

Prompt injection, plainly

Prompt injection is when text the model reads contains instructions, and the model follows them. It is not exotic. A support ticket, a PDF, a web page, a filename, a calendar invite: anything the system ingests is a place where an instruction can hide.

The dangerous version is indirect. Nobody attacks your chat window. They put text in a document your system will later summarise, and the instruction arrives through the back door.

There is no prompt that reliably prevents this, which is the point people keep missing. The mitigation is architectural: treat all retrieved content as untrusted data rather than instructions, keep the model's permissions narrow enough that following a malicious instruction accomplishes nothing, and require confirmation for anything destructive.

Where a human belongs in the loop

Human review is a guardrail, and like every guardrail it has a cost. Put it everywhere and you have built a slower version of the manual process you were trying to improve.

The placement rule is the cost of being wrong. Reversible and low consequence, let it run. Irreversible, regulated, or expensive to undo, require a person. Between those, use confidence and route the uncertain cases up.

Design the escalation path as a real product surface, not an afterthought. A queue nobody watches is worse than no escalation at all, because it creates the appearance of oversight without the substance.

How to test them

Adversarially, and on a schedule. Write the attacks down as test cases the same way you write functional tests: attempts to access another user's data, instructions hidden in retrieved documents, requests to exceed scope, inputs designed to produce a disallowed output.

Run them in CI, on every prompt change and every model update. A guardrail suite that was green six months ago tells you nothing about today, because the model underneath changed and nobody rechecked.

Track the results as numbers, not impressions, which is the same discipline described in LLM evals. And expect the suite to grow after every incident, because each one teaches you an assumption you did not know you were making.

What skipping them costs

The direct cost is the incident: exposed data, an action taken that should not have been, a public answer nobody wants to explain. The indirect cost is worse and more common. Teams that ship without guardrails end up unable to expand the system, because every new capability is a new unbounded risk and nobody will approve it.

So the feature stays trapped in a pilot, which is the outcome the whole project existed to avoid.

Guardrails are not the exciting part and they are not optional. They are why an AI feature is allowed to touch anything that matters, which is the whole point of building production AI, end to end.

If you have an AI feature reaching real users and the only thing standing between it and your data is a prompt, that is the gap to close first. Thirty minutes and you will know what it takes.

Book a call Or send the details in writing
Back to blog