Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Guardrails ai Guardrails ValidationPipeline

From Leeroopedia

Template:Principle

Overview

The Validation Pipeline principle describes how Guardrails orchestrates multiple validators to process LLM output. When a Guard is configured with several validators, they are assembled into a pipeline that governs the order of execution, the handling of individual validator results, and the aggregation of outcomes into a final validation result. This pipeline is the central mechanism through which Guardrails enforces quality constraints on generated text or structured data.

Validators within the pipeline can execute either sequentially or concurrently (via async execution). Sequential execution is the default and processes validators one at a time in their declared order, which is necessary when validators depend on the output of previous validators or when operating on streaming chunks. Concurrent execution uses Python's asyncio to run independent validators in parallel, improving throughput when validators have no data dependencies on each other.

Each validator in the pipeline is associated with an on-fail action that determines what happens when validation fails. The supported actions are: noop (log the failure but pass the output through), exception (raise a ValidationError), fix (apply the validator's programmatic fix), reask (send the output back to the LLM with corrective instructions), filter (remove the failing element from the output), and refrain (return no output at all). The pipeline aggregates these per-validator outcomes to produce the final ValidationOutcome, which includes the validated output, a pass/fail status, and any accumulated reask messages.

Theoretical Basis

The validation pipeline is an application of the Pipeline pattern (also known as Pipes and Filters), where each validator acts as a filter stage that inspects and optionally transforms data flowing through the pipeline. This pattern provides composability: validators can be added, removed, or reordered without changing the overall pipeline structure.

The on-fail action mechanism draws from strategy pattern design, where the behavior on failure is parameterized rather than hardcoded. Each on-fail action encapsulates a distinct recovery or escalation strategy. The pipeline's result aggregation follows a monadic error handling approach: each step either passes data forward or short-circuits with a specific failure mode, and the pipeline reduces these individual results into a single outcome.

Related Pages

Implementations

Workflows

(To be connected)

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment