All patterns
Security
Guardrail Layer
Input and output safety layers that filter, validate and redact before content reaches the model or the user.
clientservicemodeldatabaseagentexternal
Explanation
Input guardrails detect prompt injection, jailbreaks and PII before the model sees the input. Output guardrails detect harmful content, leaked secrets and policy violations before the user sees the response.
Components
Input classifier (injection / PII)Output classifier (toxicity / secrets)Redaction layerPolicy engineAudit log
When to use
- Any user-facing LLM product
- Regulated industries
- Agents with tool access (input + output guards critical)
When NOT to use
- Internal-only trusted tools
- Latency-critical < 200ms paths
Failure modes
- Guard model itself is bypassable
- False positives block legitimate traffic
- Guard runs but response isn't filtered
- Latency budget exceeded by guard calls
Production checklist
- Input + output guards
- PII redaction
- Secret detection
- Prompt injection classifier
- Audit log of blocked content
- Guard model versioning
- Bypass testing (red team)