All insights
AI Agents

Guardrails 101: Keeping AI Agents From Going Off-Script

AI agent guardrails work when deterministic controls limit authority, validate actions, cap impact, require approval, detect anomalies, and stop execution safely.

An AI agent passing through layered permission, validation, spending, and human approval guardrails

Use layers because no single control is enough

The agent begins with identity and a narrow role. It can discover only allowlisted tools. Every tool validates a typed request. A policy engine checks the user, data, action, destination, value, and current state. Consequential actions pause for approval. Transaction controls prevent duplicates. Monitoring catches unusual behaviour, and an operator can stop new work.

These layers answer different failure modes. A perfect schema does not prevent an unauthorised refund. An approval button does not help if the reviewer sees no evidence. A kill switch does not repair duplicate transactions already sent.

Illustrative reduction in maximum impact

Prompt instruction only
100 exposure
Allowlisted tools
72 exposure
Scoped permissions and policy
48 exposure
Budgets and transaction limits
31 exposure
Context-rich human approval
18 exposure
GuardrailExampleFailure contained
AuthorityRead invoices but never alter bank detailsExcess permission
Input/output schemaAmount must be positive and currency allowedMalformed action
PolicyRefund within role and customer limitBusiness-rule violation
BudgetMaximum spend, records, steps, and runtimeRunaway execution
ApprovalShow evidence, change, impact, rollbackHigh-consequence uncertainty
Transaction safetyIdempotency and reconciliationDuplicate or partial action
OperationsAlerts, circuit breaker, kill switchSystemic incident

Make human approval meaningful

Approval should display the requested outcome, exact proposed action, affected records, evidence, uncertainty, policy checks, financial or customer impact, and rollback plan. Route it to the person with authority and enough subject knowledge. Expire stale approvals so changed data cannot invalidate the review.

Track approval, rejection, edit, and later reversal. High approval rates do not automatically prove safety; reviewers may be rubber-stamping. Sample decisions and measure whether users understood what they authorised.

Test the guardrails as aggressively as the agent

Create cases for prompt injection, conflicting records, missing fields, excessive amounts, stale permissions, tool timeouts, duplicate requests, partial success, runaway loops, and attempts to bypass approval. Verify both refusal and recovery. Run incident drills that revoke credentials, pause queues, reconcile affected records, and notify owners.

OWASP's agentic security guidance highlights risks such as goal hijacking, tool misuse, identity and privilege abuse, unexpected code execution, memory poisoning, and cascading failures. Use external frameworks as a threat checklist, then adapt controls to the actual workflow and consequence.

Write an authority envelope for every agent

Define allowed users, purposes, data classes, tools, operations, environments, destinations, hours, transaction values, record counts, cumulative spend, runtime, concurrency, and geographic or tenant scope. Separate permission to read, recommend, prepare, approve, execute, and reverse. Default to deny when an attribute is absent or ambiguous.

Version the envelope and store the version with every action. Changes require review proportional to their new maximum consequence. Short-lived credentials and just-in-time elevation reduce exposure. Emergency revocation must stop new jobs and invalidate queued work, not merely hide a button in the interface.

The control path for a consequential action

  1. Identity

    Authenticate the actor and workload

    Resolve real user, role, tenant, session, and agent workload before capability discovery.

  2. Intent

    Validate the requested outcome

    Check purpose, task type, evidence requirements, and prohibited goals.

  3. Action

    Constrain the proposed tool call

    Validate schema, record scope, value, rate, destination, and current business state.

  4. Approval

    Pause when consequence requires it

    Give the authorised reviewer exact changes, evidence, uncertainty, impact, and expiry.

  5. Commit

    Execute transactionally

    Use idempotency, durable status, reconciliation, rollback, and immutable audit evidence.

  6. Observe

    Detect and contain

    Alert on anomalies, open the circuit breaker, reduce authority, and begin the incident runbook.

When a guardrail triggers

  1. 01

    Stop expansion

    Pause new high-impact actions, revoke or narrow credentials, and prevent queued jobs from committing.

  2. 02

    Establish the affected set

    Use trace and target-system records to identify users, data, transactions, and downstream processes.

  3. 03

    Reconcile and remediate

    Confirm actual system state, reverse safe transactions, notify owners, and preserve required evidence.

  4. 04

    Find the control gap

    Distinguish model behaviour, data, integration, policy, approval, transaction, and monitoring causes.

  5. 05

    Prove the repair

    Add the case to evaluations, test the changed control, document residual risk, and reintroduce authority gradually.

Minimum guardrail set

  • Versioned authority envelope and least-privilege identity
  • Allowlisted tools with strict input and output schemas
  • Policy, budget, rate, time, and blast-radius limits
  • Context-rich approval for consequential or uncertain actions
  • Idempotency, reconciliation, rollback, alerts, and kill switch

Frequently asked questions

Can a system prompt be an AI agent guardrail?

It is a behavioural instruction, not an enforceable boundary. Use deterministic permissions, validation, policy, and transaction controls around the model.

What is the first guardrail to implement?

Define the authority envelope and issue least-privilege credentials. If the agent cannot perform a dangerous action, many reasoning failures remain harmless.

When should a human approve an action?

Require approval when impact is high, reversal is difficult, confidence or evidence is weak, policy requires it, or the action exceeds a defined threshold.

Start with clarity

Turn the idea into a responsible next move.

Bring the context, constraint, and stakes. We’ll help clarify the most useful next decision.

Book a 30-minute fit call No generic pitch. No obligation.