Optional evaluateEvaluate user input before orchestration.
Called once per request before the orchestration pipeline starts. Use this to validate, sanitize, or block user messages.
Input and context to evaluate
Evaluation result, or null to allow without action
BLOCK to prevent the request from being processedSANITIZE with modifiedText to clean the inputnull or ALLOW to let the request throughOptional evaluateEvaluate agent output before streaming to client.
Called for response chunks based on GuardrailConfig.evaluateStreamingChunks:
true: Called for every TEXT_DELTA chunk (real-time filtering)false (default): Called only for FINAL_RESPONSE chunksResponse chunk and context to evaluate
Evaluation result, or null to allow without action
BLOCK to immediately terminate the stream with an errorSANITIZE with modifiedText to redact/modify contentOptional configConfiguration for evaluation behavior. Controls streaming vs final-only evaluation and rate limiting.
Contract for implementing custom guardrail logic.
Guardrails intercept content at two points:
Both methods are optional—implement only what you need.
Example: Basic content filter
Example: Mid-stream "changing mind" (cost ceiling)
Example: PII redaction mid-stream