Interface Guardrail

All Known Subinterfaces:
AgentResponseGuardrail, ModelCallGuardrail, TextGuardrail, ToolCallGuardrail
All Known Implementing Classes:
ModelCallSimilarityGuard, SimilarityGuard

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

A Guardrail needs to implement exactly one of ToolCallGuardrail, ModelCallGuardrail or AgentResponseGuardrail, which extend this interface, and have a public constructor optionally taking a GuardrailContext parameter (the guardrail's configured name and config section).

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 report-only is false and a guardrail denies the call, or fails with fail-mode = fail-closed.
    static interface 
    A message in the conversation a guardrail inspects, carrying its origin: what the user said, what the model replied (and which tools it requested), and what a tool returned.
    static final record 
    Deprecated, for removal: This API element is subject to removal in a future version.