Guardrail

org.llm4s.agent.guardrails.Guardrail
trait Guardrail[A]

Base trait for all guardrails.

A guardrail is a pure function that validates a value of type A. Guardrails are used to validate inputs before agent processing and outputs before returning results to users.

Type parameters

A

The type of value to validate

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def name: String

Name of this guardrail for logging and error messages.

Name of this guardrail for logging and error messages.

Attributes

def validate(value: A): Result[A]

Validate a value.

Validate a value.

This is a PURE FUNCTION - no side effects allowed. Same input always produces same output.

Value parameters

value

The value to validate

Attributes

Returns

Right(value) if valid, Left(error) if invalid

Concrete methods

def andThen(other: Guardrail[A]): Guardrail[A]

Compose this guardrail with another sequentially.

Compose this guardrail with another sequentially.

The second guardrail runs only if this one passes.

Value parameters

other

The guardrail to run after this one

Attributes

Returns

A composite guardrail that runs both in sequence

def description: Option[String]

Optional description of what this guardrail validates.

Optional description of what this guardrail validates.

Attributes