Skip to content
Dashboard

5 AI agent guardrails that hold in production

Copy link to headingKey takeaways

Copy link to heading5 AI agent guardrails at a glance

Copy link to headingAgent guardrail #1: Validate input wherever untrusted content enters the context

Copy link to headingLayer deterministic checks under classifiers

Copy link to headingAgent guardrail #2: Scope tool permissions to the task

Copy link to headingLeast privilege belongs outside the model

Copy link to headingAgent guardrail #3: Gate irreversible actions behind human approval

Copy link to headingDesign against approval fatigue

Copy link to headingAgent guardrail #4: Cap steps, time, and spend before each call

Copy link to headingMultiple independent ceilings

Copy link to headingAgent guardrail #5: Validate output and filter what leaves the system

Copy link to headingStructural, grounding, harmful-content, and PII checks

Copy link to headingWhat output checks can't reach

Copy link to headingHow to implement AI agent guardrails on Vercel

Copy link to headingRun input and output checks as AI SDK middleware

Copy link to headingPut typed tool contracts and approvals on one agent object

import { ToolLoopAgent, isStepCount, tool } from 'ai';
import { z } from 'zod';
const agent = new ToolLoopAgent({
model: process.env.AGENT_MODEL,
tools: {
readOrder: tool({
inputSchema: z.object({ orderId: z.string() }),
execute: async ({ orderId }) => readOrder(orderId),
}),
refundOrder: tool({
inputSchema: z.object({ orderId: z.string(), amount: z.number() }),
execute: async ({ orderId, amount }) => refundOrder({ orderId, amount }),
}),
},
toolApproval: {
refundOrder: async ({ amount }, { runtimeContext }) => {
if (runtimeContext.role !== 'admin') {
return { type: 'denied', reason: 'Only admins can issue refunds' };
}
return amount > 100 ? 'user-approval' : undefined;
},
},
stopWhen: isStepCount(10),
experimental_toolApprovalSecret: process.env.TOOL_APPROVAL_SECRET,
});

Copy link to headingIsolate tool execution with Vercel Sandbox

Copy link to headingKeep spend and audit in one control plane with AI Gateway

Copy link to headingMove AI agent guardrails into the runtime

Copy link to headingFrequently asked questions about AI agent guardrails

Copy link to headingWhere should guardrails run in the agent request path?

Copy link to headingDo AI agent guardrails stop prompt injection?

Copy link to headingHow much latency do AI agent guardrails add?

Copy link to headingWhich agent actions need human approval?

Ready to deploy?