Input Guardrails in Practice
The placement rule, not a fixed count, decides how many guardrails a design needs. Every exposure you identify is a place where a guardrail may belong.
A Design That Looks Finished
Imagine you have built a simple application. A person types a question, the question is passed to a model, and the model's answer appears on the screen. Nothing in the design looks broken. Yet the design raises an uncomfortable question: what happens if the text coming in is harmful, misleading, or simply not something the application should handle? And what happens if the text going out is the problem?
Guardrails are the design answer to that question. This article follows one request through a simple application, explains what a guardrail is and whose risks it covers, and shows how the two broad families of guardrails divide the work between them. Keep the simple two-point flow in mind, text comes in and text goes out, because the rest of the article builds on it.
Following One Request Step by Step
The best way to see how guardrails fit into an application is to follow one request from start to finish. Read the trace below as a sequence of states. At each step, ask which exposure is currently active, meaning which point in the system could let something go wrong, and which guardrail, if any, is responsible for it.
- 1State 1: The person types a question into the application. Text is now arriving from outside the system, so the entry point is an exposure.
- 2State 2: The question is passed to the model. The text is now inside the processing, where a risk can travel further.
- 3State 3: The model produces an answer. The answer is now the content that will leave the system, so the exit point is an exposure.
- 4State 4: The answer appears on the screen. The person reading it is the one who receives whatever risk survived the earlier stages.
Notice that the trace has two edges that matter most. The first is where text enters the application. The second is where text leaves it. Those two edges are where the two families of guardrails are placed, as the next sections explain.
What a Guardrail Is For
A guardrail is a mechanism that mitigates risk and protects both the builder and the users of an application.
The word mechanism matters. A guardrail is not a single rule written in a document. It is a component of the system that actively limits what can go wrong. Its job is defensive. It does not make the application more capable, faster, or more interesting. It exists so that when a risk is present, the consequences of that risk are contained before they reach a user or the operator running the system.
Because a guardrail is defined by what it prevents rather than what it adds, you can test any proposed guardrail with one question: which specific risk does this contain, and where in the flow does it contain it? If you cannot answer both parts, the proposal is still a wish, not a guardrail.
Whose Risks Guardrails Cover
The phrase protect you and your users captures two audiences. The builder is exposed to risks such as an application behaving in ways that reflect poorly on the product or create legal or operational trouble. The users are exposed to risks such as receiving harmful content or having their own information handled carelessly. A well-placed guardrail considers both audiences, because a risk to one is usually a risk to the other.
Locating Exposures in the Flow
The source gives a clear placement rule: guardrails should be put wherever there is an exposure to risk. This turns a vague worry into a concrete design task. Instead of asking whether the application feels safe, you walk through the system and ask at which points risk can enter, travel, or leave.
An exposure is a point in the system where something could go wrong and cause harm. Exposures are not all the same size. Some sit at the edges of the system, where data arrives from outside or leaves to the outside. Others sit inside the processing itself. The placement rule asks you to put a guardrail at each exposure you can identify, rather than relying on one check at the very beginning and hoping it covers everything.
The placement rule, not a fixed count, decides how many guardrails a design needs. Every exposure you identify is a place where a guardrail may belong.
Tracing the Request With Guardrails in Place
Now trace the same request again, this time with the two families placed on it. The input guardrail handles the question on its way in, before it reaches the model. The output guardrail handles the reply on its way out, before it reaches the screen. Each guardrail covers a distinct stretch of the flow, so they never handle the same data at the same moment.
| Feature | Input guardrail | Output guardrail |
|---|---|---|
| Side of the flow | Data coming into the application | Data going out of the application |
| Position | Before the model processes the text | After the model produces its answer |
| Protects | Against risk arriving with the request | Against risk leaving with the reply |
| Shared purpose | Mitigate risk and protect builder and users | Mitigate risk and protect builder and users |
The two families share a purpose and differ in position.
The table makes a point easy to miss when the two families are studied in isolation. They share a purpose and differ only in position. That is why a complete design usually considers both, and why the placement rule about exposures is what decides how many guardrails are needed.
Placing Guardrails in a Question Answering App
Locating exposures in a question answering application
A small application lets a person type a question, sends it to a model, and shows the answer. Where do the exposures sit, and which family of guardrail covers each one?
- 1Identify the entry point
The question arrives from outside the system. This is an exposure at the edge, where data comes in.
- 2Identify the processing
The question is handed to the model. Risk that got past the entry point can still travel into this processing, so the flow must be considered as a whole.
- 3Identify the exit point
The model's answer leaves the system and reaches the screen. This is an exposure at the edge, where data goes out.
- 4Assign the families
The entry exposure is covered by an input guardrail. The exit exposure is covered by an output guardrail. Because the two families cover opposite ends of the flow, the design needs both.
Two exposures sit at the edges of the application, so the design calls for an input guardrail on the question and an output guardrail on the answer. Covering only one edge leaves the other exposure unprotected.
Common Mistakes When Placing Guardrails
Common mistake Treating a guardrail as a single rule written in a document
Why it failsThe source describes a guardrail as a mechanism, a component of the system that actively limits what can go wrong.
Do this insteadDescribe the guardrail by the component that performs the check and the exposure it covers.
Common mistake Relying on one check at the very beginning of the flow
Why it failsThe placement rule asks for a guardrail at each exposure, including exposures inside the processing and at the exit.
Do this insteadWalk the flow, list each point where risk can enter, travel, or leave, and decide which of them need a guardrail.
Common mistake Thinking only about the user, or only about the builder
Why it failsGuardrails protect both audiences, and a risk to one is usually a risk to the other.
Do this insteadFor each guardrail, name the builder risk and the user risk it addresses.
Common mistake Assuming an input guardrail also covers the reply
Why it failsInput and output guardrails cover opposite ends of the data flow, so they never handle the same data at the same moment.
Do this insteadCheck the entry and the exit separately, and place a guardrail on each exposure you find.
Predicting Where Harmful Text Is Caught
What do you think happens?
A person sends a harmful question to the application. Which family of guardrail is positioned to handle that text first, before the model processes it?
Reveal answer
An input guardrail
The source places input guardrails on data coming into the application, before it is passed to the model. Output guardrails handle the reply on its way out, so they are not the first point of contact for the question.
Take a simple application where a user types a question, the question goes to a model, and the answer appears on the screen. List every exposure you can find, then for each one state whether an input guardrail or an output guardrail covers it, and name one builder risk and one user risk that the guardrail addresses.
Hints
- Start with the two edges of the flow: where text enters and where text leaves.
- Remember that exposures can also sit inside the processing itself, not only at the edges.
Key Takeaways
- A guardrail is a mechanism that mitigates risk and protects both the builder and the users of an application.
- Guardrails should be placed wherever there is an exposure to risk, so the design task starts by locating exposures.
- Input guardrails cover data coming into the application, and output guardrails cover data going out; both share a purpose but differ in position.
- A risk to the builder is usually a risk to the user as well, so a well-placed guardrail considers both audiences.