# Guardrails

AI Glossary · Governance, Risk & Ethics
Canonical URL: https://aisat.uk/glossary/guardrails
Author: Lucy Gilmore, Assistant General Counsel, Product, Privacy & AI at Sprinklr | Practical Privacy, Product & AI Governance & Defensible Risk Decisions (https://www.linkedin.com/in/lucy-gilmore/)
Breadcrumb: [Glossary](https://aisat.uk/glossary) > [Governance](https://aisat.uk/glossary?category=governance) > Guardrails

## TL;DR

> **Guardrails** are programmatic validation and policy layers placed around a language model's inputs and outputs to enforce safety, security, accuracy, and compliance rules at runtime. They block prompt injections, redact personal data, verify citations, and ensure responses conform to approved schemas.

## How Guardrails works in practice

Because a language model is probabilistic, system prompt instructions such as 'Never mention competitors or reveal personal data' are polite suggestions rather than hard engineering guarantees. Guardrails wrap the model call inside a deterministic and statistical enforcement pipeline that inspects traffic at three checkpoints: input rails (before the prompt hits the LLM), tool/execution rails (before an agent invokes an external function), and output rails (before the completion reaches the user).

Input rails run fast checks such as PII detection and masking (replacing UK National Insurance numbers, NHS numbers, and credit cards with placeholders), topic classification to reject off-domain requests, and prompt-injection heuristics. Tool rails verify that agent function calls respect RBAC permissions, spend caps, and parameter allowlists. Output rails enforce JSON Schema grammar, check groundedness against retrieved RAG passages, strip hallucinated URLs, and block toxic or regulated financial-advice statements.

For instance, a UK retail bank runs a two-stage guardrail pipeline on its customer chat assistant: sub-10ms regex and Microsoft Presidio NER checks scrub sort codes and account numbers on ingress, while a lightweight classifier model verifies on egress that no response contains unregulated mortgage recommendations.

## Why it matters and trade-offs

Guardrails separate a fragile prototype from an enterprise-grade system that security and compliance officers can sign off. They provide defence in depth: even if a base model update changes tone or a user crafts a clever adversarial prompt, independent output and tool rails prevent data leakage, brand damage, or unauthorised API mutations.

The engineering trade-off is latency and false-positive friction. Stacking three heavy LLM-based guardrail checks onto every turn can add two seconds of latency, double token costs, and frustrate legitimate users when overly aggressive topic filters block valid questions. Teams should push as many checks as possible into zero-latency deterministic rails (JSON Schema constrained decoding, regex validators, and code assertions) and reserve neural guardrail models for nuanced semantic policies.

## Related AI concepts

- [Prompt Injection](https://aisat.uk/glossary/prompt-injection): Prompt Injection is a security vulnerability in which adversarial instructions submitted directly by a user or hidden indirectly inside retrieved web pages, emails or documents override a language model's system prompt to hijack tool calls or exfiltrate data.
- [Hallucination](https://aisat.uk/glossary/hallucination): Hallucination is a failure mode in which a generative AI model outputs confident, fluent statements that are factually false, fabricated or unsupported by source documents because it predicts statistically plausible tokens rather than verifying truth.
- [Evals (Evaluations)](https://aisat.uk/glossary/evals): Evals (Evaluations) are automated, repeatable testing pipelines that score an AI application's outputs against a golden dataset using deterministic assertions, reference metrics and LLM-as-a-judge rubrics before any prompt or model change ships.
- [AI Governance](https://aisat.uk/glossary/ai-governance): AI Governance is the operational framework of internal policies, model inventories, risk assessments, approval gates, human oversight rules and audit trails that an organisation uses to deploy artificial intelligence safely, ethically and legally.
