﻿# Pydantic AI text deltas bypass output validators

Pydantic AI stream_text(delta=True) emits raw text without output validators; accumulated snapshots, TextOutput transformations and saved final messages follow different paths.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/guide-pydantic-ai-text-delta-validation/
Language: en

## Separate display fragments from accepted text

A client appends every arriving text fragment to a report preview. An output validator normally checks that source identifiers are present and may transform the text. Pydantic AI's [output guide](https://pydantic.dev/docs/ai/core-concepts/output/) states that `stream_text(delta=True)` returns raw deltas and skips output validators. Smooth incremental display therefore does not establish that the displayed content passed the application's ordinary final-output acceptance rule.

## Compare delta and snapshot consumption

The [result API](https://pydantic.dev/docs/ai/api/pydantic-ai/result/) distinguishes deltas from accumulated text. With snapshot consumption, each value represents text accumulated so far; the guide says validators can transform those snapshots. Appending snapshots as though they were deltas duplicates content. Conversely, replacing the entire document with each delta drops prior text. Choose the consumer update behavior according to the actual stream representation rather than merely the method's familiar name.

## Keep TextOutput processing explicit

The guide also explains that `stream_text` does not apply `TextOutput` functions. Use the documented `stream_output` path when the intended output is the value produced by such a function. A processing function might normalize references or construct a domain object from text. Reading raw text bypasses that transformation even when the function was configured as part of the agent's output design; it should not be described as already processed application output.

## Preserve the accepted message deliberately

The [history guide](https://pydantic.dev/docs/ai/core-concepts/message-history/) discusses message availability for streamed runs, and the output guide notes that delta text consumption does not add the final output message to result messages. Do not assume a screen containing the whole report guarantees that the same final message is available for conversation persistence. Define how validated final output and retained history are obtained before building continuation around that assumption.

## Assign side effects to a completed validation step

Keep incremental rendering separate from publishing a report or writing an annotation derived from its content. [Task contracts](/journal/learn-codex-task-contract/) establish the completed artifact, while [tool observations](/journal/learn-codex-tool-observation/) retain which validation and transformation path produced it. Partial snapshots may invoke validators repeatedly, so validators should not casually publish each intermediate value. A useful implementation accepts one deliberate final result and labels the streaming preview according to the guarantees it actually has.
