In short.
This Pydantic AI Harness guide helps Python developers add live model-based review to agent runs, but that review adds model usage and offers corrections without enforcing safeguards. TrajectoryJudge periodically examines a bounded conversation transcript and returns either AllGood or Steer, which queues corrective guidance for a subsequent model request. Reviews run concurrently outside durable execution and are awaited inside durable workflows. The page explains integration and operational trade-offs, but supplies no measured correction accuracy, latency results or monetary prices.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage is limited to the complete documentation page at https://pydantic.dev/docs/ai/harness/trajectory-judge/index.md, including its 0.x API-change notice, examples and API reference. Linked source code, version-policy details, other guides and provider pages are excluded. Runtime behavior, security resistance, correction quality, latency, costs and compatibility were not tested.
The overview
Identity
The resource is the Trajectory Judge documentation for Pydantic AI Harness at [https://pydantic.dev/docs/ai/harness/trajectory-judge/index.md]. It combines a feature guide, Python examples and an API reference for TrajectoryJudge, AllGood and Steer.
Its purpose is to help developers attach a reviewing model to an agent so that problems can be noticed while work continues. The page links to implementation source at [https://github.com/pydantic/pydantic-ai/tree/main/src/pydantic_ai_harness/pydantic_ai_harness/trajectory_judge/], but that linked code is outside the available evidence.
Assessment
The guide is useful for planning oversight of long agent runs that may accumulate unsupported claims or drift beyond the original task. It explains both the integration surface and consequential behavior such as skipped reviews, cancelled evaluations and propagated errors.
Its practical effectiveness remains unknown. The page provides no measured evidence of how often a judge detects drift, issues an incorrect correction or improves task completion. Documented behavior was not tested.
Users
The primary audience is Python developers building agents with Pydantic AI and Harness capabilities. Examples focus on checking evidence behind claims, spotting scope creep and reviewing security risks.
Developers using Temporal, DBOS or Prefect also receive guidance on durable execution. Beginners can follow the basic capability example, while advanced customization assumes familiarity with Agent configuration, structured output, callbacks and shared usage limits.
Capabilities
TrajectoryJudge evaluates recent user messages, assistant messages, tool calls and tool results. Each evaluation produces one verdict: AllGood leaves the run alone; Steer carries corrective guidance that is queued for delivery on the next model request. Steering remains in the conversation by default.
Multiple judges can monitor different concerns independently, with separate names and schedules. The on_verdict callback receives processed verdicts, including steering after it has been queued. A custom judge Agent can supply model settings, toolsets and fallback models.
Using it
Requirements
The examples use Agent from pydantic_ai and TrajectoryJudge from pydantic_ai_harness, together with a configured judge model. Installation commands, supported Python versions, exact compatible package versions and provider credential setup are not specified.
Configure either model with optional instructions, or a full agent; these approaches are mutually exclusive. A supplied judge Agent receives no dependencies and must not have output validators. Each evaluation enforces output_type=[AllGood, Steer], regardless of that Agent's configured output type.
Mechanism
The after_model_request hook counts model requests and triggers evaluation at each configured interval. The defaults are every=10 and window=20000. Transcript length is estimated at roughly four characters per token. When the transcript exceeds the window, the initial request is retained up to half the window, followed by recent activity; history from earlier runs is dropped first.
Outside durable execution, evaluation runs concurrently with the agent. Each judge permits only one evaluation in progress, skips a scheduled review if the previous one is still running, and cancels unfinished evaluation when the agent run ends. The transcript reflects request-hook changes, so removed or redacted tool results do not reach the judge.
Steering uses typed JudgeSteeringPart and JudgeFeedbackPart messages. The judge's text is identified as model-written user-channel data, with a random reference tying it to an application note. The framing distinguishes recognized feedback from forged or repeated feedback elements; its resistance to attacks is not measured on the page.
Setup
Import TrajectoryJudge and add an instance to the main Agent's capabilities list. Set its model, describe the review concern through instructions, and choose every and window for the intended review frequency and context size. Add on_verdict to observe decisions.
Inside a durable workflow or flow, assign each judge a distinct id. An id-less judge is rejected before the first model request. Evaluations are checkpointed and awaited, allowing replay to reuse the recorded verdict. The on_verdict callback runs again during replay, so callbacks that write externally need to be idempotent.
Example
The introductory example attaches a judge with every=20 to an agent asked to fix a flaky checkout test and add a regression test. Its review instructions focus on claims unsupported by files the agent actually read. A separate example adds another judge that checks for work outside the original request every ten model requests.
These examples demonstrate configuration and intended use. They provide no run transcript, observed verdicts or verified test outcome, so they do not establish that either judge successfully corrected an agent.
Assessment & evidence
Limitations
A judge observes and steers; it does not block or rewrite actions. Periodic evaluation, a limited transcript window, skipped intervals and cancellation at run end leave gaps in coverage. The initial request is preserved only within the documented window allocation, and older context may be unavailable.
Stored JudgeFeedbackPart messages let later reviews recognize earlier steering, but UI adapters omit capability parts. History returned from a frontend therefore lacks that steering for subsequent review. TrajectoryJudge also cannot be serialized into an agent spec because it may contain a live Agent and callback.
Judge failures can fail the main run: outside durable execution they surface at the next cadence tick or run end; inside a workflow or flow they surface from the request that launched evaluation. A custom Agent with model fallback can provide an alternative failure path. If the main run is already failing, the judge outcome is discarded so it does not mask that error.
Reasoning
The strongest reason to use this feature is a review condition that requires interpreting the course of a conversation, such as whether recent work still answers the original request. Persistent steering and visibility of earlier feedback give later evaluations context about attempted corrections.
Whether that benefit justifies extra usage depends on the workload and judge quality. The page establishes the mechanism, but does not establish reliable detection, reduced total cost or prevention of harmful actions. Enforcement still needs an appropriate boundary outside the judge's advisory verdict.
Alternatives
The page recommends rule-based System Reminders first when a condition does not require model judgment; these avoid an extra model call. Its LLMReminder alternative also has a second model read the run, but adds a reminder at every firing, whereas TrajectoryJudge can return AllGood without adding guidance.
Guardrails serve the enforcement role at input, tool-call and output boundaries. Post-run evaluations assess completed runs, when correction may require another run. These distinctions come from this page; the linked alternatives were not separately assessed.
Evidence
The evidence consists of the complete Trajectory Judge page at [https://pydantic.dev/docs/ai/harness/trajectory-judge/index.md], including its narrative, Python examples and API reference. It supports the configuration and behavior described here.
The page supplies no benchmark dataset, execution logs or empirical reliability results. Linked implementation files, provider documentation and related feature pages are outside the evidence, so their contents and compatibility remain unassessed.
Access & freshness
Costs
Monetary cost is unknown: the page gives no package price, model rates or worked cost estimate. Reviews add model usage and potentially tool usage when the custom judge has tools. Review frequency, transcript size, model choice and the number of judges affect that additional usage.
Judge usage contributes to the parent run's usage and shares its usage_limits. Each evaluation reserves one request before launch; a review that cannot fit the request budget is skipped. In durable execution, the documentation says replay reuses the recorded evaluation and avoids billing it again, although evaluation adds waiting time to the original run.
Rights
The page links to source code but does not state the documentation or implementation licence. Permission to redistribute either is therefore unknown from this evidence. Commercial-use conditions and model-provider terms are also not established.
The judge receives conversation content, including tool results. Provider retention, processing location and contractual treatment of that content are not described.
Freshness
The page was captured on 24 November 2026. Its publication date, last update and exact package version are not stated. It warns that Pydantic AI Harness APIs may change between minor releases while the package remains on 0.x releases.
Model identifiers differ across examples. Their availability and compatibility are not established by the page, so they should be treated as illustrative configuration values rather than verified model recommendations.
Actions
Start with one clearly defined review concern and choose a judge model available in the intended environment. Confirm package compatibility, provider setup and licence terms, then configure cadence, window and shared usage limits. Ensure conversation content is suitable for the chosen judge provider.
Before relying on it, observe on_verdict results on representative runs and assess missed drift, unnecessary corrections, added usage and failure propagation. For durable execution, use distinct judge ids and replay-safe callbacks. Keep action-blocking requirements in guardrails or other enforcement mechanisms.
