Explainer2 min read

What Are AI Guardrails? The Layers That Matter

Guardrails are not a single filter you bolt on. They are layers, and most of them live outside the model. A prompt that says "be careful" is not a guardrail.

TrueCodeAI Engineering
Agents, Voice & ML practice
Published
GuardrailsExplainerSecurity
Hand entering a code on a secure keypad

The five layers

Guardrail layers, from outermost to innermost
LayerWhat it doesExample
InputScreens what comes inDetect prompt injection, strip secrets, block off-topic abuse
PermissionsLimits what the agent can doRead-only tools by default; scoped API keys
ApprovalsPuts a human on risky actionsRefunds above a threshold need sign-off
OutputChecks what goes outSchema validation, PII redaction, policy checks
MonitoringCatches what slipped throughAlerts on unusual actions, sampled human review

Put guardrails in code, not prompts

Instructions in a prompt are suggestions the model usually follows. Permissions in code are rules it cannot break. If an action must never happen — deleting records, paying out above a limit — enforce it in the tool layer where the model has no say.

Balancing safety and usefulness

Over-strict guardrails produce an assistant that refuses everything and gets abandoned. The goal is proportionate control: light touch on low-risk answers, hard stops on irreversible actions. We tune thresholds using evals that include both attacks and normal questions.

Frequently asked questions

Do guardrails slow the system down?

Well-designed checks add little latency. Heavy checks can run only on risky actions.

Can a model be fully jailbreak-proof?

No model is. That is why permissions and approvals, which do not depend on the model, carry the real weight.

Are guardrails needed for internal tools?

Yes — internal tools often have more powerful access. Scope permissions to the user’s own rights.

Tell us what you want to exist.

We reply within 24 hours at hello@truecodeai.com with how we would build it.

Get a fixed price WhatsApp