Skip to main content
The --guardrail flag enables LLM-based output validation to ensure agent responses meet specific criteria.

Quick Start

Guardrail Validates Output Quality

Usage

Basic Guardrail

Expected Output:

Combine with Other Flags

Common Guardrail Criteria

Security

Quality

Content

Format

How It Works

  1. Agent Execution: The agent processes your prompt normally
  2. Validation: The guardrail LLM evaluates the output against your criteria
  3. Result: Pass/fail status is displayed with feedback

Examples

Code Quality Guardrail

Expected Output:

Content Guardrail

SQL Safety Guardrail

Best Practices

Be specific with your guardrail criteria. Vague criteria may lead to inconsistent validation.
Guardrails add an additional LLM call, which increases latency and token usage. Use --metrics to monitor costs.