Base interface for guardrails.

Guardrails protect AI agents by validating inputs and outputs against safety, privacy, and policy constraints.

class PIIGuardrail implements Guardrail {
readonly name = 'pii-detection';
readonly description = 'Detects personally identifiable information';

async evaluate(context: GuardrailContext): Promise<GuardrailResult> {
const violations = this.detectPII(context.content);

if (violations.length > 0) {
return {
passed: false,
severity: GuardrailSeverity.ERROR,
reason: 'PII detected in content',
violations,
};
}

return { passed: true };
}
}
interface Guardrail {
    name: string;
    description: string;
    enabled: boolean;
    evaluate(context: GuardrailContext): Promise<GuardrailResult>;
}

Methods

Properties

Methods

Properties

name: string

Unique name of the guardrail

description: string

Human-readable description

enabled: boolean

Whether this guardrail is enabled