Quality failures in model outputs
An output guardrail catches failures in model output and specifies a policy for each failure mode.
A Reply That Should Not Reach the User
A language model does not produce its answer the way a calculator produces a sum. Its reply is generated text, and that text can go wrong in many different ways. It might come back empty, break the format an application depends on, state something untrue, or contain content that no product should show to a customer. An application that passes every reply straight through to the user is trusting the model completely, and that trust is rarely justified in a production system.
What do you think happens?
A model reply comes back completely empty. Should the application pass it straight to the user, or should something check it first?
Reveal answer
Check it first. An empty reply is one of the failures the guardrail is meant to catch.
The source lists an empty reply among the ways generated text can go wrong. Because the application can detect that the reply is empty, it can apply a policy to it instead of showing it to the user.
The Output Guardrail as a Checkpoint
An output guardrail catches failures in model output and specifies a policy for each failure mode.
An output guardrail is the checkpoint placed between the model and the user. Its purpose is to examine what the model produced before the application acts on it. A guardrail is not a model improvement and does not make the model smarter. It is application logic that inspects results and decides what should happen when a result is not acceptable.
The guardrail does not need to know how the model works internally. It only sees the output and the expected standard. This is why guardrails can be added to an application without changing the model itself.
A guardrail has two responsibilities, and they depend on each other. The first is detection: the guardrail must catch outputs that fail to meet the standards the application sets. The second is response: once a failure has been caught, the guardrail must apply a policy that says what to do about that particular kind of failure. Detection without a policy leaves the application stuck with a bad reply. A policy without detection never gets triggered.
Tracing a Response Through the Checkpoint
It helps to picture a response moving through a sequence of decisions. The model's output enters the guardrail, which runs its checks. A response that passes goes on to the user. A response that fails is matched to a failure category, and the policy for that category determines the next step. The diagram below shows this route. Pay attention to the fork at the check, because the same response can take two very different paths depending on what the check finds.
Read the diagram as a route, not a single step. A passing response leaves the guardrail immediately. A failing response is classified, and the category's policy decides whether it loops back for another attempt or leaves the automated path entirely. The new attempt returns to the same check, so every retry is inspected again before it can reach the user.
Quality Failures Versus Security Failures
Failures look different across applications, so the first skill in designing a guardrail is recognizing what failure looks like for a specific product. The source sorts common failures into two families. Quality failures concern whether the output is good and correct. Security failures concern whether the output is safe and whether it exposes something it should not.
- Quality example: a reply that arrives empty, because the application has nothing usable to show.
- Quality example: a reply that breaks the format the application depends on, so downstream code cannot read it.
- Quality example: a reply that states something untrue, so it is not correct.
- Security example: a reply containing toxic content that no product should show to a customer.
- Security example: a reply exposing private content that the application should not reveal.
Mapping Each Failure Mode to a Policy
Detection tells the guardrail that something went wrong. The policy tells it what to do. Each failure mode needs its own policy, because a empty reply and a toxic reply should not be handled the same way. The map below pairs example failure modes with an example policy for each. The pairings are illustrations of the design decision, not fixed rules from the source.
Assigning a policy to a new failure
A support application receives a reply that is well formatted and nonempty, but it states a refund policy that does not exist. Which failure family does it belong to, and what policy should the designer consider?
- 1Identify the family
The reply is well formatted and not empty, so it is not a format or empty-reply failure. It states something untrue, which the source places under factually inconsistent responses in the quality family.
- 2Check whether detection is possible
A policy only fires if the guardrail can catch the failure. The designer must decide how the guardrail detects a made-up policy, since the reply looks fine on its surface.
- 3Choose a policy
A retry may produce a different answer, but it is not guaranteed to be correct. A human fallback may suit a request where the stakes are high. The designer picks a policy that fits the product.
The failure is a quality failure. Its policy depends on how well the guardrail can detect it, and the designer must choose the policy knowing that detection is the weak link.
Retries, Cost, and Latency
Many failures can be reduced with simple retry logic. The reason it works is that AI models are probabilistic. Sending the same query again may produce a different response. If the reply came back empty, the application can try again a fixed number of times or until a nonempty reply arrives. If the reply was malformatted, it can keep trying until the format is correct. A retry policy is therefore a rule that converts a failure into another attempt, with a defined stopping condition.
A retry policy is not free. Every retry is another round of API calls, which means extra latency and extra cost. If the retry happens only after a failure has been observed, the user waits for the first attempt and then for the second, so the latency the user perceives can roughly double. Parallel calls avoid waiting, but they add redundant API calls, which still cost money.
| Strategy | API calls for a failing query | User wait before a result | Risk |
|---|---|---|---|
| Return fallback immediately | 1 | One attempt | User gets fallback without a retry |
| One retry after failure | 2 | Roughly two attempts in sequence | Latency roughly doubles |
| Several retries after failure | Up to 1 plus the retry count | Grows with each retry | Cost and latency keep rising |
| Parallel calls | Several at once | Close to one attempt | Redundant calls add cost |
Illustrative comparison of retry strategies. Counts follow the sequential and parallel behavior described in the source; the rows are a generated summary.
Handing Off to a Person
Retries assume another model response will be good enough. For some requests that assumption is weak, and the policy should send the conversation to a person instead. Human fallback handles tricky requests, and its trigger is only as good as the detection behind it. If the detection misses a tricky request, no fallback will ever run.
- Phrase-based transfer: any query containing specific phrases is sent to human operators.
- Model-based transfer: a specialized model decides when to transfer. One team transfers the conversation when its sentiment analysis model detects anger in the user's messages.
- Turn-based transfer: the conversation is transferred after a set number of turns, which stops users from getting stuck in a loop.
Tracking False Refusals
Tightening a guardrail to block more security failures sounds like pure improvement. But every check that flags more content also flags some content that was acceptable. A reply that was safe and useful gets refused, and the user receives a fallback they did not need. This is a false refusal. The guardrail refused something it should have passed.
This is why both numbers have to be measured together. A team that tracks only security failures can keep tightening the check and never notice that the application is refusing more and more acceptable replies. Tracking the two side by side shows whether a stricter policy is actually improving the product or only shifting the errors.
Mistakes to Avoid in Guardrail Design
Common mistake Treating the guardrail as a way to make the model smarter
Why it failsA guardrail is application logic that inspects results. It does not change how the model generates text.
Do this insteadDescribe the guardrail as a checkpoint that decides what happens when a result is not acceptable.
Common mistake Retrying every failure the same way
What it looks likeAn empty reply and a toxic reply both get sent back to the model.
Why it failsEach failure mode needs its own policy. A retry suits a probabilistic format or empty-reply failure, but it does not fit every case.
Do this insteadAssign a specific policy to each failure mode, such as retry, human fallback, block, or pass.
Common mistake Assuming retries cost nothing
Why it failsEach retry adds API calls, latency, and cost. Parallel calls add redundant calls.
Do this insteadCount the calls and the waiting time for each retry policy before choosing a stopping condition.
Common mistake Trusting a human fallback trigger that never fires
Why it failsThe fallback only runs when detection catches the request. A weak trigger means tricky requests are never handed off.
Do this insteadTest the trigger against real tricky requests and check that it is actually firing.
Common mistake Measuring only security failures
Why it failsA stricter check also produces false refusals of acceptable replies, and those costs are invisible if only security failures are tracked.
Do this insteadTrack false refusals alongside security failures.
Practice: Route a Response
A guardrail returns a malformatted reply for a customer lookup. Trace the path it takes through the guardrail. Name the failure family, the policy you would assign, and what the user sees if the retry limit is reached. Then say what you would also measure to make sure the guardrail is not refusing acceptable replies.
Hints
- Which family does a malformatted reply belong to, and which failure families did the source describe?
- A retry loops back to the check. What is the stopping condition, and what happens after it?
- Think about whether a stricter check could refuse a reply that was actually fine.
Putting the Checkpoint Together
- 1An output guardrail is application logic placed between the model and the user. It has two dependent jobs: detection of failures and a policy for each failure mode.
- 2Quality failures concern whether output is good and correct, such as empty, malformatted, or factually inconsistent replies. Security failures concern whether output is safe and whether it exposes what it should not, such as toxic or private content.
- 3Retries can fix many probabilistic failures, but each retry adds API calls, latency, and cost. Human fallback handles tricky requests, and its trigger is only as good as the detection behind it.
- 4A stricter guardrail can produce false refusals, so false refusals must be tracked alongside security failures.
Key Takeaways
- An output guardrail catches failures in model output and specifies a policy for each failure mode.
- Quality failures cover empty, malformatted, or factually inconsistent replies; security failures cover toxic or private content.
- Retry policies fix many probabilistic failures but add latency and cost, and human fallback depends on the quality of detection.
- False refusals must be tracked alongside security failures, because stricter checks can refuse acceptable replies.