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 }; }} Copy
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 }; }}
Evaluate content against this guardrail
Evaluation context
Result of the evaluation
Readonly
Unique name of the guardrail
Human-readable description
Whether this guardrail is enabled
Base interface for guardrails.
Guardrails protect AI agents by validating inputs and outputs against safety, privacy, and policy constraints.
Example