Interface Guardrail

All Known Subinterfaces:
TextGuardrail
All Known Implementing Classes:
SimilarityGuard

public sealed interface Guardrail permits TextGuardrail
Guardrails can protect against harmful inputs and outputs to/from model and tool calls.

A Guardrail needs to implement TextGuardrail, which extends this interface, have a public constructor with optionally a GuardrailContext parameter, which includes the name and the config section for the specific guardrail.

Guardrails are enabled for agents with configuration, see agent documentation.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    Thrown when the text didn't pass the evaluation criteria, and report-only is true.
    static final record 
    The result of the guardrail evaluation.