Zenaique

Match each safety check to the rail it belongs on

Match pairs·Easy·4.0 · 0·~2 min·Asked atComet MlEyLakera
Attempt it

Drag each answer to line up with its matching prompt

Detect a user pasting an AWS secret key

Output rail

Redact a phone number the model echoed in its answer

Action rail

Block a tool call to delete_customer when the user never asked

Output rail

Quarantine instructions embedded in a retrieved web page

Input rail

Detect 'ignore all previous instructions' in the user message

Retrieval rail

Strip Markdown image tags that exfiltrate data via URL parameters

Input rail

TL;DR

Safety checks live on four rails, input (before the model), retrieval (when external content arrives), action (when a tool call is proposed), and output (before the response leaves), each rail handles the threats

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Picture a kitchen with four doors: the pantry door for ingredients, the back door for deliveries, the stove door for cooking, and the dining-room door for plates going out. A safety inspector watches each one separately. The pantry door checks what the user brings in. The back door checks deliveries from outside. The stove door checks whether the cook is about to do something dangerous. The dining-room door checks whether the plate that is about to leave has anything on it that should not be served. Each problem belongs at the door closest to its cause, because that is where you have the right tools to deal with it.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Production guardrail stacks are most useful when they are organised by boundary, the moment data crosses into or out of the LLM application, rather than by topic, what the safety check is looking for. The four-rail model (input, retrieval, action, output) is the dominant default because each rail corresponds to a real boundary in the system and to the right point of intervention for the threats that show up there.

This card walks through each rail in turn, then explains the principle behind the separation, and finishes with the operational consequences of getting the placement right or wrong.

The four rails and what each one owns

Input rail. The user has typed a message and your application has received it. Before the message becomes part of an LLM prompt, the input rail inspects it. Common checks include direct prompt-injection detection (the classic ignore all previous instructions), PII paste detection (the user dropped a Social Security number or an AWS access key), off-topic filtering, jailbreak signature matching, and language-policy enforcement. The action is typically refuse with message or redact then continue.

Retrieval rail. Your application has fetched external content into context, a RAG document, a web page, a tool response with substantial text. Before that content joins the prompt, the retrieval rail inspects it. The dominant threat is indirect prompt injection: instructions hidden in retrieved content that the model may follow as if they were authoritative. Common checks include injection classification at chunk granularity, denied-source filtering, and tagging or quarantining suspicious chunks. The action is typically annotate with trust level or drop from context.

Action rail. The model has proposed a tool call. Before the runtime executes the tool, the action rail inspects the call. Common checks include tool allowlisting per agent or session, argument schema validation, blast-radius classification (read-only versus mutating versus destructive), confirmation prompts on irreversible operations, and step-budget enforcement. NeMo Guardrails calls this the execution rail; the substance is the same.

Output rail. The model has produced a response and your application is about to return it to the user. Before the response leaves your perimeter, the output rail inspects it. Common checks include PII redaction on model-generated text, dangerous-Markdown stripping (image and link tags pointing to non-allowlisted domains), toxicity classification, citation presence enforcement, and structured-output schema validation.

Why boundary-based instead of topic-based
Why retrieval and action need to be their own rails
Operational consequences of getting the placement right
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • NVIDIA NeMo Guardrails encodes the four rail types as explicit Colang flow categories, input, output, retrieval, execution.
  • AWS Bedrock Guardrails separates content policies (input/output) from sensitive information filters and topic policies, layered with model-side tool-use validation.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you instrument so that you can answer the question, which rail blocked the most requests this week?
A

Emit per-rail counters with category labels; tie blocks to a structured outcome enum the dashboard groups on.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Putting every check on the input rail because it is the obvious entry point; many threats (model echoing PII, malicious tool calls, injection in retrieved content) cannot be caught there at all.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Names of the four rails and what fires at each boundary

  • Why PII can land on either input or output depending on origin

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Pick the strongest reason…
MCQ·Medium