Skip to main content

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

  1. User text → Input checks (mask personal data, injection, on topic)
  2. Input checks (mask personal data, injection, on topic) → Model
  3. Model → Output checks (advice, promises, other customers' data)
  4. Output checks (advice, promises, other customers' data) → fail → Regenerate once, then a safe template
  5. Output checks (advice, promises, other customers' data) → pass → Action checks (limits, recipients, approvals)
  6. 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

Practise it on these questions

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.