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 Stream Result Handling

From Leeroopedia
Knowledge Sources
Domains Streaming, Data_Structure
Last Updated 2026-02-14 00:00 GMT

Overview

A result handling principle for consuming incremental validation outcomes from a streaming Guard execution and accessing the full result after stream completion.

Description

Stream Result Handling addresses two consumption patterns for streaming validation: (1) per-chunk consumption during streaming, where each yielded ValidationOutcome contains the validated segment text and its pass/fail status, and (2) post-stream access to the full concatenated result via guard.history.last, which contains the complete raw and validated output.

This dual-access pattern supports both real-time display (per-chunk) and post-processing (full result) use cases.

Usage

During streaming: iterate over the generator, accessing each chunk's validated_output and validation_passed. After streaming: access guard.history.last for the full result including the complete Call object with all iterations and logs.

Theoretical Basis

Two consumption phases:

  1. Real-time phase: Each ValidationOutcome in the generator provides: validated_output (the text segment), validation_passed (boolean), and raw_llm_output (accumulated raw text)
  2. Post-stream phase: guard.history.last provides: iteration.outputs.raw_output (full raw text), iteration.outputs.validation_response (full validated text)

Related Pages

Implemented By

Page Connections

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