Learning resourcesReviewed · Pydantic

Pydantic Evals Online Evaluation Guide

Pydantic Evals’ Online Evaluation guide shows Python developers how to monitor live AI outputs, but checks can be silently skipped when too many run at once. It explains background evaluators, configurable sampling, OpenTelemetry events, custom result handlers and integration with Pydantic AI agents.

Researched 14 Nov 2026

In short.

Pydantic Evals’ Online Evaluation guide teaches Python developers to score live AI functions and agents, but background scoring does not guarantee complete coverage or result delivery. It documents reusable evaluators, sampling, concurrency limits, OpenTelemetry export and custom sinks. Its strongest use is ongoing quality monitoring with explicitly chosen checks. Failed calls need separate configuration, delivery errors can be suppressed, and durable workflows introduce replay, serialization and shutdown constraints. Performance, judging accuracy and deployment costs are not established.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage is the complete documentation page at [https://pydantic.dev/docs/ai/evals/online-evaluation/index.md], including examples, sampling, sinks, telemetry attributes, stored-context reuse, error handling, agent integration and durable-execution notices. Linked pages, package releases, external specifications, pricing and licence documents are excluded. Documented deprecation applies to older durable-agent wrappers. Installation, execution, judging accuracy, load behavior, shutdown delivery, workflow replay and data handling were not tested.

The overview

Identity

This documentation guide covers online evaluation through pydantic_evals.online and the OnlineEvaluation capability for Pydantic AI agents. Online evaluation means attaching checks to staging or production calls and scoring their outputs in the background.

The same Evaluator classes can also be used with Dataset.evaluate() for offline evaluation. The guide’s central contribution is explaining how to connect those checks to live calls, control their frequency and deliver their results. Original source: [https://pydantic.dev/docs/ai/evals/online-evaluation/index.md].

Assessment

The documented controls make this a useful starting point for teams that want inexpensive checks on most traffic and more expensive model-based judging on a smaller sample. Reusing evaluator classes across offline datasets and live calls can also help teams maintain consistent evaluation logic.

Use its scores for monitoring and follow-up action: the documented background scheduling allows a response to return before evaluation finishes. Assessing suitability therefore depends on whether sampled, potentially incomplete feedback meets the application’s needs. The page supplies implementation guidance but no measured reliability or performance results.

Users

The guide is aimed at Python developers maintaining LLM applications, agent services or other functions whose outputs need ongoing checks. Relevant tasks include tracking rubric scores, spotting quality changes after deployments and preparing real traffic for later analysis.

Beginners will need familiarity with Python functions, decorators and basic asynchronous execution. Experienced developers get details about evaluator identity, telemetry attributes, custom storage adapters and durable workflow behavior. Pydantic AI users have a dedicated agent integration; the function decorator also supports ordinary synchronous and asynchronous Python functions.

Capabilities

Evaluators can return pass/fail values, numeric scores, categorical labels or mappings of named results. Each evaluator can have its own sampling rate, concurrency limit, sink and error settings. Sampling can be static, driven by runtime configuration or based on inputs; correlated sampling lets several checks evaluate the same subset of calls.

Custom sinks receive results, evaluator failures, context, a span reference and the evaluated target. Evaluator versions and serialized constructor specifications help distinguish scoring configurations over time. Conditional evaluators can omit expensive checks when their conditions are unmet.

The guide also explains rerunning evaluators against stored EvaluatorContext data without rerunning the original function. External storage retrieval uses an EvaluatorContextSource implementation. JSON round-trips use Pydantic TypeAdapter with concrete field types to preserve supported Python types faithfully.

Using it

Requirements

The examples require a Python environment with the illustrated pydantic_evals APIs available. Agent examples additionally use Pydantic AI. The page does not establish installation commands, minimum Python versions, compatible package versions or the release that introduced these features.

To receive default telemetry events, configure an OpenTelemetry SDK and export path, such as Logfire or another instrumentation setup. Without an SDK, default emission is a no-op. Python sinks provide an additional result-handling route. Model configuration and provider requirements for LLMJudge are not established by this page.

Durable agent integrations require an appropriate durability capability and a stable identifier for OnlineEvaluation. Engines that serialize operation arguments also require suitable serializable inputs and metadata.

Mechanism

The evaluate() decorator uses a global OnlineEvalConfig unless a separate configuration instance is supplied. For decorated functions, sampling occurs before the function runs. When no evaluator is selected, the documentation says evaluation instrumentation is avoided. Selected evaluators are dispatched in the background using an existing event loop or a background thread with its own loop.

The agent capability builds context from a completed run, including its output, prompt, token usage, duration and span tree. Streaming evaluation waits until a final result exists and the surrounding context manager exits. With durable execution, sampling and dispatch happen inside a recorded operation after the run.

Each evaluator result or evaluator failure emits a gen_ai.evaluation.result OpenTelemetry event by default, associated with the originating span. Boolean results receive numeric and pass/fail representations; numeric and string results have different score fields. Target, evaluator source, optional version and a shared scoring-run identifier support attribution. Additional sinks can receive batched results from several evaluators for the same call.

Setup

Define an Evaluator subclass or evaluator function, then attach it through evaluate() or a custom OnlineEvalConfig. Wrap individual checks in OnlineEvaluator when they need explicit sampling, concurrency or routing settings. For a Pydantic AI agent, add OnlineEvaluation to its capabilities and give the agent a useful name for result grouping.

Configure telemetry export during application startup, or register a sink for Python-side handling. Set on_max_concurrency to observe dropped checks, on_error to observe delivery failures and on_sampling_error to handle failing sampling callbacks. Enable run_on_errors on checks intended to inspect failed application calls.

The asynchronous examples use wait_for_evaluations() before inspecting collected results. This demonstrates waiting for pending work; production shutdown behavior and delivery reliability still require assessment in the intended deployment.

Example

The introductory example defines OutputNotEmpty, whose evaluate() method returns bool(ctx.output), and attaches it to an asynchronous summarize(text) function with evaluate(OutputNotEmpty()). The function returns its summary while the evaluator runs in the background.

For a truthy output, the documented telemetry representation includes a score of 1.0 and a pass label. This particular check establishes only that the output is truthy: an irrelevant but nonempty answer would also pass. A separate example configures an LLMJudge with a helpfulness rubric, a 0.01 sampling rate and a maximum of five concurrent evaluations. These are illustrative settings, with no demonstrated judging accuracy or savings.

Assessment & evidence

Limitations

Each OnlineEvaluator defaults to a concurrency limit of 10. Additional evaluation requests are dropped rather than queued, and drops are silently ignored without an on_max_concurrency callback. Application calls that raise are excluded by default; run_on_errors=True supplies the exception as the evaluator’s output while preserving its propagation to the caller.

A failing sampling callback propagates to the caller unless on_sampling_error handles it and skips that evaluator. Exceptions in sinks, telemetry delivery or concurrency callbacks are silently suppressed without on_error. Evaluator exceptions instead become EvaluatorFailure objects. These different paths require separate monitoring.

Durable execution records dispatch without waiting for evaluation completion. If a worker stops before checks finish, their results can be lost even though the engine has recorded the operation. Prefect flow retries can dispatch evaluations again; the guide recommends sink deduplication using the agent run identifier.

Temporal serialization changes inputs, outputs and metadata into JSON representations, removes access to the span tree and changes how exceptions reach evaluators. Adding the durable operation can also break replay for workflows already in flight. The guide recommends letting those workflows finish or retaining workers on the earlier version.

Reasoning

A practical implication of the documented sampling and dropping behavior is that scores describe the calls actually evaluated. They cannot automatically establish quality across all traffic. Under load, concurrency drops may further change which calls receive scores, so coverage information matters alongside score trends.

Evaluator versioning is useful when a changed rubric or heuristic alters what a score means. Recording a version makes historical results distinguishable, but does not itself establish that the evaluator measures the desired business outcome. The page provides no calibration study, human agreement measurements or evidence that its example checks detect specific production regressions.

Alternatives

For curated cases before deployment, the page points to offline evaluation with Dataset.evaluate(), using the same evaluator classes. For historical outputs, run_evaluators() provides a route to apply additional checks without re-executing the original application function.

For result handling, the page describes Logfire’s Live Evaluations view, other configured OpenTelemetry backends and custom Python sinks. These are documented integration choices; linked pages were outside scope, so their features, prices and comparative suitability were not independently assessed. No competing evaluation framework is assessed.

Evidence

The evidence is the complete Online Evaluation documentation page at [https://pydantic.dev/docs/ai/evals/online-evaluation/index.md], including its embedded Python examples, configuration descriptions and execution caveats. Its source snapshot has SHA-256 b2d6c335c52dacf44595b0214caed0937cdb3854cad5f1790a3823fde250e18e.

The examples establish documented usage and intended behavior. No code was executed, and their displayed outputs are not observed test results. Linked API references, external specifications and service documentation were not assessed. Independent performance, accuracy, reliability and cost measurements are absent.

Access & freshness

Costs

The page gives no prices for model judging, Logfire or other telemetry services, and no measured CPU, memory, latency or storage overhead. Total deployment cost is unknown.

Sampling and conditional checks can reduce evaluation volume. Correlated sampling can concentrate multiple checks on the same requests: the guide’s example gives approximately 27% of calls receiving at least one check with three independent 10% samples, versus approximately 10% when those samples are correlated. These probabilities describe coverage, not measured financial savings.

Concurrency limits restrict simultaneous evaluations and drop excess work. They do not establish a spending budget, a maximum monthly bill or guaranteed result coverage.

Rights

The supplied page does not state a software licence or a licence governing reuse of its documentation and examples. Commercial use, modification and redistribution permissions cannot be established from this evidence.

The page also does not establish model-provider data terms, telemetry-backend retention policies or contractual rights concerning captured traffic. Those terms remain unknown.

Freshness

The source was captured on 14 November 2026 at 22:46:19.407 UTC. The supplied page establishes no package release number or last-updated date, so compatibility with any particular installed version is unknown. The capture timestamp does not establish a software release date.

The guide labels TemporalAgent, DBOSAgent and PrefectAgent wrappers as deprecated and recommends durability capabilities for the described replay behavior. It also warns that its additional gen_ai.evaluation.target and gen_ai.evaluation.evaluator.* telemetry attributes may change as OpenTelemetry conventions evolve.

Under Temporal, an unhandled sampling error can cause repeated activity retries; the page states that the default retry policy has no attempt limit. Deployment-specific retry behavior and compatibility remain untested.

Actions

Begin with a representative staging function and a simple evaluator whose meaning is easy to inspect. Confirm compatible package versions, configure a visible result destination and choose explicit sampling and concurrency settings. Assess the check against representative outputs before interpreting its scores as a quality signal.

Exercise successful calls, failed calls, sampling exceptions, delivery failures and concurrency drops. Check that pending evaluations finish during the intended shutdown sequence, inspect which context and baggage fields reach telemetry destinations, and confirm applicable software and service terms.

For durable agents, verify stable capability identifiers, serialization behavior and replay compatibility with existing workflow histories. Account for duplicate evaluations on Prefect retries and possible result loss after dispatch. Establish actual judging and telemetry costs before increasing evaluation volume.

Evidence for this report

selected-page.txtselected · checked 2026-11-14