AI Guardrails

AI guardrails are controls placed around an AI model that check its inputs, outputs and actions against rules, and block, rewrite or escalate anything that breaks them.

Also known as: LLM guardrails, safety filters, safety rails

Related terms in this glossary

How it works

Guardrails sit outside the model, in the application. They run before the prompt reaches the model, after the model responds, or before a tool call executes. Common types include:

  • Input checks: detecting prompt injection attempts, off-topic requests or personal data that should not be sent.
  • Output checks: filtering toxic content, redacting secrets, validating format and checking claims against source documents.
  • Action checks: permission rules, spending limits and human approval before a tool performs anything irreversible.
  • Topic and policy rails: keeping a support bot on its product and away from medical or legal advice.

They can be rules and regular expressions, classifier models such as Meta's Llama Guard, or frameworks such as NVIDIA NeMo Guardrails that combine several checks.

Why it matters

A model's built-in safety training is general, while your policies are specific. Guardrails turn your policies into enforced behavior and create an audit trail. They are not a complete defense. Classifiers miss novel attacks and flag harmless requests, and each check adds latency. The strongest control is architectural: give the model only the data and permissions the task needs, so a failure has limited impact. Treat guardrails as one layer alongside least privilege, evaluations and monitoring. The NIST AI Risk Management Framework and its 2024 Generative AI Profile describe this layered approach. Gepton tests guardrails in AI security and red teaming.

AI Guardrails in depth

Where guardrails sit in a request

A guardrail is only as good as its position. In a typical assistant or agent, checks run at four points:

  1. Before the model: classify the user input for injection attempts, abuse and out-of-scope topics; redact personal data such as Aadhaar or card numbers that the model does not need.
  2. Around retrieval: filter documents by the user's access rights before they reach the context, so the model never sees what the user may not see.
  3. Before tools run: validate arguments against a schema and policy, such as refund amount within limits, and send irreversible actions to a person.
  4. After the model: validate format, check claims against sources, block disallowed content and strip secrets before the reply leaves.

Example: a guardrail stack for a banking FAQ assistant

Example: a hypothetical bank's public assistant answers product questions. Input rails reject requests for account-specific actions and redirect them to the authenticated app, and a classifier flags known jailbreak patterns. Retrieval only searches published product pages. Output rails block any sentence that states an interest rate not present in the retrieved pages, refuse investment advice, and add a link to the source page. Every block is logged with the rule that fired. Weekly review of those logs shows which rules are firing on harmless requests and need tuning.

Tools and implementation choices

ApproachGood forWatch out for
Rules, regex, allow listsPII patterns, schema checks, limitsBrittle against rephrasing
Classifier models (for example Llama Guard)Content safety categories, injection detectionFalse positives, extra latency
Frameworks (for example NeMo Guardrails, Guardrails AI)Combining checks, dialogue rails, validatorsAnother layer to version and test
Provider moderation endpointsQuick baseline safety checksGeneric policies, not yours
Code-level permissionsLimiting what tools can do at allRequires design effort up front

For Indian deployments, test classifiers on Hindi, Hinglish and regional-language input. Many were trained mostly on English and miss or over-flag other languages.

Measuring guardrails

Every guardrail has two error rates. Measure how often it misses harmful or out-of-policy input, using an attack set from red teaming, and how often it blocks legitimate requests, using a sample of real traffic. Track the added latency at p95. Re-run both sets when you change the model, since a new model may behave differently behind the same rails.

Common mistakes

  • Relying on the system prompt as a guardrail. Instructions are guidance to the model, not enforcement.
  • Checking only the user's message while ignoring documents, web pages and tool results, the usual path for prompt injection.
  • Stacking so many checks that the assistant becomes slow and refuses ordinary questions.
  • No logging of blocks, so nobody can tune or prove the controls.

Guardrails defend against jailbreaks and injection and support AI governance with evidence. We design and test them in AI security and red teaming and AI governance and ethics.

Questions about AI Guardrails

Something else? Send us your question and an engineer replies with next steps.

Do guardrails slow down an AI assistant noticeably?

They can, depending on how they are built. Rule-based checks add almost nothing. Classifier calls and model-based output checks add a network round trip each, and running them one after another adds up. Common ways to keep latency in check are running input checks in parallel with retrieval, using small dedicated classifiers instead of a large model, checking streamed output in chunks, and reserving the heaviest checks for high-risk actions. Measure end-to-end response time at the 95th percentile with and without the rails.

Can guardrails stop an AI agent from making a wrong payment or deleting data?

Guardrails help, but the strongest protection is not giving the agent the ability in the first place. Scope its credentials so it cannot reach payment or delete operations unless the task requires them. Where it does need them, enforce limits in code, such as maximum amounts and allowed accounts, and require a person to approve before the action runs. A classifier that inspects the agent's intent is a useful extra layer, but it should never be the only thing between the agent and an irreversible action.

Jump to

↑↓ to move↵ to open