Tools & Approvals
Guardrail Check
Live safety and policy gate for an agent payload — streams policy checks, highlights flagged spans inline, toggles Redacted vs Original, and lets you allow or block with undo.
2 variantsMIT
Preview
Guardrail check
billing-agent · before reply delivery
Scanning
Assistant output
Refund issued for order #8492. Receipt sent to maya.chen@northstar.io using live key sk_live_51Nx92kQp8Lm4vR9xT2z. Funds arrive in 3–5 business days.
Policy checks
Scanning
Installation
Copies the component into components/ui and installs its dependencies and theme tokens.
pnpm dlx shadcn@latest add https://tuffui.com/r/guardrail-check.jsonUsage
Pass your own data and wire the callbacks to your agent runtime.
import { GuardrailCheck } from "@/components/ui/guardrail-check";
export function OutputGate({ scan, onResolve }: Props) {
return (
<GuardrailCheck
content={scan.text}
findings={scan.findings}
checks={scan.checks}
subtitle="billing-agent · before reply delivery"
onDecision={(decision) => onResolve(decision)}
/>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| content* | string | — | The prompt, tool payload or assistant response being scanned. |
| findings* | GuardrailFinding[] | — | Flagged character ranges inside `content`, each with a severity and redaction replacement. |
| checks* | GuardrailRuleCheck[] | — | Policy checks executed on the payload, with status and latency. |
| status | "scanning" | "passed" | "flagged" | "blocked" | — | Overall gate status. Derived automatically from `checks` when omitted. |
| direction | "input" | "output" | "output" | Labels the preview as a prompt payload or assistant output. |
| view | "redacted" | "original" | — | Controlled preview mode. |
| defaultView | "redacted" | "original" | "redacted" | Starting preview mode when uncontrolled. |
| onViewChange | (view: "redacted" | "original") => void | — | Called when the user toggles between Redacted and Original. |
| decision | "allowed_redacted" | "allowed_original" | "blocked" | null | — | Controlled resolution state after the user acts. |
| onDecision | (decision: GuardrailDecision | null) => void | — | Called when the user allows redacted, allows original, blocks, or clicks Undo. |
| title | ReactNode | "Guardrail check" | Header title. |
| subtitle | ReactNode | — | Secondary line under the title, e.g. agent name and stage. |
| className | string | — | Extra classes for the outer Shell. |
type GuardrailFinding = {
id: string;
ruleId: string;
label: string;
severity: "warning" | "critical";
start: number;
end: number;
replacement: string;
reason?: string;
confidence?: number;
};
type GuardrailRuleCheck = {
id: string;
name: string;
status: "checking" | "passed" | "flagged" | "blocked";
latencyMs?: number;
detail?: string;
};