翻篇收录说明
翻篇网页快照

What are AI guardrails? Types, examples, and how they work

https://telnyx.com/learn-ai/ai-guardrails

最近抓取:2026-12-05 02:18:29(北京时间)

最近内容变化:2026-12-02 13:47:31(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

AI guardrails are run-time checks on what goes into and comes out of an AI model. How they work, the main types, examples, and guardrails for AI agents.

正文摘录

Back to GlossaryWhat are AI guardrails? Types, examples, and how they workAI guardrails are run-time checks on what goes into and comes out of an AI model. How they work, the main types, examples, and guardrails for AI agents.Editor: Maeve SentnerUpdated October 2026AI guardrails are checks that run around an AI model while it is in use. They inspect what goes into the model, such as the prompt and retrieved text, and what comes out, such as the response or a tool call. Anything that breaks the developer's policy is flagged, blocked, rewritten or escalated to a person. LLM guardrails are the same checks applied to applications built on large language models.Large language models arrive with safety training built in, yet Zou and colleagues found that an automatically generated string of text, added to the end of a harmful request, got three public chatbots past that training.Guardrails put the final decision about what reaches a user, a database or a phone line in the application, where the developer controls it.What are AI guardrails?An AI guardrail is a rule enforced outside the model. It has three parts: a written policy, a detector that checks each request or response against it, and an outcome, such as a block, when the detector fires.The model cannot switch a guardrail off, because the guardrail is not part of the model. The same guardrail works with any underlying large language model.Safety training sits inside the model: methods such as Constitutional AI change its weights so it declines harmful requests and explains why.Prompt instructions differ from both: a system prompt asks the model to behave, while a guardrail checks whether it did.The term also has a policy sense: in law and corporate governance, "AI guardrails" and "ethical guardrails" mean the rules for how AI may be built and used, not checks that software runs on each request.Why do AI systems need guardrails?AI systems need guardrails because a model's training does not reliably stop it from being manipulated, leaking data, stating false facts or taking unsafe actions.The OWASP Top 10 for large language model applications, a ranking of the most serious security risks, puts prompt injection first and sensitive information disclosure second for 2025.Prompt injection is input that changes the model's behavior in ways the developer did not intend.A model can also fail with no attacker involved, by producing a hallucination: a fluent answer that is false. The US National Institute of Standards and Technology lists it, as confabulation, among 12 risks in its Generative AI Profile.Safe AI responses come from a check matched to each risk: input checks against injection and data leakage, output checks against harmful or unsupported answers, and action checks on what an agent may do.How do AI guardrails work?AI guardrails work by running a detector at fixed checkpoints in an AI application and acting on what it finds. An input check runs before the model, an output check runs after it, and in an agent an action check runs before any tool executes.Each detector looks for a policy violation and returns one of five outcomes:Allow lets the request or response through unchanged.Flag lets it through and logs the finding for review.Block stops it, and the application returns a refusal or an error instead.Rewrite changes it, for example by masking a card number, and lets the new version through.Escalate hands it to a person or a stricter process, such as a human agent or a second verification step.In a support chat, a customer pastes a card number into a refund question. A rule in the application's code masks the number before the model sees it: a rewrite.The output check then confirms the answer promises nothing the refund policy forbids: an allow.Behind each check is a detector of one of three kinds: rules, trained classifiers or model judges. Rules match exact patterns without a model call, such as a checksum test that finds card numbers or a list of banned phrases.Trained classifiers sort text into risk categories. Llama Guard, for example, is a language model fine-tuned to label both prompts and responses against a safety taxonomy.A model judge is a second language model given the policy in plain words and asked whether a prompt or response breaks it. It handles nuanced policies that no pattern or fixed category describes.The moderation rails in NeMo Guardrails work this way: a separate model vets each user message before the main model sees it, and each response before the user does.Types of AI guardrailsThe four main types of AI guardrails are named for what they inspect: input, output, retrieval and action guardrails.Input guardrailsInput guardrails check what users and other systems send to the model. They catch jailbreak attempts and prompt injections, keep secrets and personal data from reaching the model provider, and turn away off-topic requests.Output guardrailsOutput guardrails check what the model produces before anyone sees it. Content filters block hate speech and other harmful categories; other checks catch leaked personal data, broken formats and claims the business may not make.Retrieval guardrailsRetrieval guardrails check the documents a model reads, in systems that ground answers in retrieved text.Before the model runs, one check screens retrieved passages for hidden instructions. Afterwards, another tests whether the answer follows from them.Action guardrailsAction guardrails sit between an agent and its tools. They decide whether a proposed tool call is allowed, whether its arguments are valid, and whether a person must approve it first.Other taxonomies sort the same checks by owner (data, model, application, infrastructure) or by purpose (security, privacy, safety, accuracy, compliance).Examples of AI guardrailsA common example of an AI guardrail is a refund limit on a support agent. The agent issues refunds up to a set amount on its own, and anything larger waits for a person to approve it.Three other common guardrails, with the trigger and the outcome for each:A topic check on a bank's support bot declines off-topic requests, such as poems or medical advice, and offers the bot's real scope instead.A grounding check compares each answer with the retrieved policy document and blocks any sentence the document does not support.A brand and compliance check on AI-written marketing copy looks for banned claims, missing disclaimers and off-brand terms before anything publishes, then sends a failing draft back for revision.Guardrails for AI agentsGuardrails for AI agents check actions as well as words, because an agent's output can call a tool that moves money, changes a record or ends a phone call.OWASP calls the failure excessive agency and traces it to three causes: tools the agent does not need, permissions broader than the task, and high-impact actions taken without approval.Two action guardrails answer those causes directly, and two more catch bad inputs and runaway loops:Least privilege gives the agent only the tools its task needs, and each tool only the permissions its job needs.Approval gates make irreversible or high-value actions wait for a person to confirm.Argument checks validate each tool call's inputs, such as an account ID that must belong to the caller, before the tool runs.Limits on steps, retries and spend stop an agent that loops.On a phone call, an agent's tools act on the call itself. An agent built on a programmable Voice API can transfer, hang up or send keypad tones, so each of those tools needs its own permission check.Agents also read content they did not write, which opens a second path for attacks. Greshake and colleagues showed that instructions planted in a web page or document can redirect an assistant that retrieves it.The working rule is that retrieved content is data, never instructions. OWASP's prompt injection mitigations put it into practice: the application labels retrieved text as untrusted, keeps it apart from its own instructions and filters it.Can AI guardrails be bypassed?AI guardrails can be bypassed. OWASP's own guidance says it is unclear whether any method fully prevents prompt injection.A rephrased jailbreak, a new language or an encoding the detector has not seen can slip past it. The adversarial suffixes that Zou and colleagues generated even worked on models they were never trained against.A classifier or model judge is itself a model, so it can be attacked too. Mangaokar and colleagues built an adversarial prefix that carried harmful responses past several guard models, even with no access to the guard model itself.The model's own safety training is no backstop either: Qi and colleagues fine-tuned a commercial model on 10 harmful examples, at a cost of under $0.20, and it then followed nearly any harmful instruction.The realistic goal is layers: input, output and action checks that fail differently, logs that show what each one caught, and a person on the path for the decisions that matter most.How to implement AI guardrailsImplementing AI guardrails starts with a written policy for each risk, then attaches a detector and an outcome to each policy at the stage where that risk enters or leaves the application.The team writes a policy for each risk: what the application must never accept, say or do, and what gets flagged instead of blocked. A bank's support bot and a coding assistant need different lists.Each risk gets the cheapest detector that reliably catches it: a rule for a fixed pattern, a classifier for a harm category, and a model judge only where the policy needs judgment.Each stage gets an outcome for a match (block, flag, rewrite or escalate) and, for a classifier, a confidence threshold before it acts.Tests run in both directions. A public attack set, such as the AdvBench prompts from Zou and colleagues, plus attacks from the application's own logs, shows what the guardrails catch; normal traffic shows what they wrongly block.Every flag and block goes in a log that records