Pattern · Safety
Guardrail layers
Checks before the model (input), after it (output) and before any action, each logged with its reason.
Say it in the interview
I would layer guardrails: rules and a classifier on input, a model check on output with one regeneration then a safe fallback, and hard limits in code before any action, logging every trigger so we can tune false positives.
When to use it
- Customer-facing assistants
- Regulated domains
How it works
- User text → Input checks (mask personal data, injection, on topic)
- Input checks (mask personal data, injection, on topic) → Model
- Model → Output checks (advice, promises, other customers' data)
- Output checks (advice, promises, other customers' data) → fail → Regenerate once, then a safe template
- Output checks (advice, promises, other customers' data) → pass → Action checks (limits, recipients, approvals)
- Action checks (limits, recipients, approvals) → The tool runs
Trade-offs
- Defence in depth
- Every check adds latency; false positives annoy users
Pitfalls interviewers probe
- One giant system prompt as the only guardrail
- Checks with no logging, so nobody can tune them