In short.
Refine Output is a guide for Python developers who want Pydantic AI agents to revise completed answers, but every review adds model requests and the page provides no accuracy measurements. It documents RefineOutput configuration, repeated output validation, streaming behavior and cases where review is skipped. The same model performs the review with its tools available. Actual costs, latency and quality improvements are unknown, and the page warns that the 0.x API can change between minor releases.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage is limited to the complete selected page at [https://pydantic.dev/docs/ai/harness/refine-output/index.md], including installation, configuration, API reference, execution exceptions, durable execution, telemetry, composition and the 0.x compatibility notice. Linked documentation, the documentation index, GitHub implementation, package artifacts, release history and license files are excluded. No commands, code or model calls were executed. Runtime behavior, provider availability, accuracy, latency and actual charges remain unverified.
The overview
Resource identity
This documentation page explains RefineOutput, an optional behavior attached to a Pydantic AI Agent through the pydantic-ai-harness package. It asks the model to review and rewrite its answer before the run finishes.
The guide includes installation, configuration examples, execution rules and an API reference. The original page is [https://pydantic.dev/docs/ai/harness/refine-output/index.md].
Practical assessment
The guide is useful when an agent should have another opportunity to inspect a completed answer and additional model requests are acceptable. It provides concrete integration details, including important exceptions that could otherwise leave an application expecting a review that never happens.
Its descriptions establish how the feature is intended to operate, not how often it improves an answer. Accuracy gains, error rates and response-time effects are not assessed.
Who it is for
The primary audience is Python developers building Pydantic AI agents. Developers working with structured responses, streaming interfaces or durable execution will benefit from the detailed integration rules.
Beginners get a short installation example and an explanation of the review cycle, but the page assumes familiarity with agents and model configuration. It does not provide a complete Python introduction or provider-authentication tutorial.
What it supports
RefineOutput defaults to one review round per run. Developers can change rounds and supply custom instructions. During review, the model can use its tools and is instructed to give the complete answer again, revised; only the last answer becomes the run's output.
Structured outputs are produced again on each pass, with output validators and output functions running for every answer. Multiple RefineOutput instances track their own rounds and can contribute different instructions to the same review round.
The capability emits no tracing spans of its own. On an instrumented agent, each review appears as an ordinary model request in the trace.
Using it
Requirements
The examples require a Python environment, a Pydantic AI Agent, the pydantic-ai-harness package and a configured model. Supported Python versions, exact dependency versions and provider access requirements are not specified on this page.
A custom Model implementation must set model_name on its responses for those responses to be reviewed. RefineOutput treats responses without that field as outputs that did not originate from a model request and skips review.
How review works
When a run would finish with a model-generated output, RefineOutput adds a system prompt asking the model to inspect its previous answer and return a revised, complete answer. The earlier answer remains in message history. The review prompt also remains there under the default conversation scope.
The prompt uses SystemPromptPart metadata containing origin pydantic-ai-harness.refine_output.v1 and the round number. A fresh instance created by for_run holds each run's counter, so runs do not share used rounds. Summarizing away review instructions through compaction does not reset the counter.
For durable execution, the page explains that after_node_run recounts rounds over journaled responses during workflow replay in Temporal, DBOS or Prefect. That replay behavior is documented but has not been independently assessed here.
Setup
The documented installation commands are pip install pydantic-ai-harness and uv add pydantic-ai-harness. Import Agent from pydantic_ai and RefineOutput from pydantic_ai_harness, then pass capabilities=[RefineOutput()] when constructing the agent.
The page's example constructs Agent('anthropic:claude-opus-5-5', capabilities=[RefineOutput()]). That identifier is an example in the documentation; its availability, account requirements and pricing are not established by this page.
Example use
For reviewing a source-based answer, the page shows RefineOutput(rounds=2, instructions='Check every figure against the source documents, then answer again.'). This configures two review rounds with a specific checking instruction.
In practical use, checking those figures would require access to the relevant documents through the conversation or tools. The instruction alone does not establish that the model verifies every figure correctly, and the page provides no execution result for this example.
Assessment & evidence
Limitations and integration concerns
Review is skipped when a run pauses with DeferredToolRequests, returns PendingModelResponse while a provider is still processing, or produces an output that did not come from a model request. The latter includes an input guardrail blocking the prompt.
Agent.run_stream() ends at its first streamed output and does not perform this review. For reviewed streaming, the page directs developers to Agent.run() with an event_stream_handler or Agent.iter(). Streaming consumers can see the initial answer and subsequent revisions even though only the last answer is final.
Output validators and output functions run on every answer, so the page explicitly advises keeping them free of side effects. Review quality is not guaranteed by the documented mechanism.
Why the approach may help
The mechanism gives the same model another opportunity to identify omissions, unclear wording or unsupported claims, with tools still available for checking. It operates on an answer that has already been accepted as output.
Because the same model performs the review, it is reasonable to expect that some original mistakes could survive the second pass. This is an inference from the design, not a measured result. The evidence does not establish whether additional rounds outperform one round or an independent reviewer.
Related approaches
The page contrasts RefineOutput with Trajectory Judge, which uses a second model to review a run while it is in progress. RefineOutput uses the existing model and acts on the output.
It also distinguishes output guardrails, which reject outputs that violate a rule. RefineOutput instead requests another look at an accepted answer. These are brief comparisons on the selected page; their implementation details, relative costs and comparative effectiveness are not assessed.
Evidence and confidence
The evidence consists of the complete documentation page at [https://pydantic.dev/docs/ai/harness/refine-output/index.md], including its usage examples and API reference.
Behavioral descriptions are supported by that documentation. The page provides no benchmark results, execution logs or independent evaluations. Runtime correctness, compatibility and quality improvements have not been tested.
Access & freshness
Costs and usage
Each review round requires at least one additional model request, and more requests can follow when the model calls tools. These requests count toward UsageLimits like other requests. Two review rounds therefore require at least two extra model requests.
The page supplies no package price, provider rates, tool charges, monetary estimates or latency measurements. Actual financial cost remains unknown and depends on the configured services and usage.
Licensing and permissions
The supplied page contains no license terms for the package or documentation. Commercial-use conditions and redistribution permissions are therefore unknown from this evidence.
The page links to implementation source at [https://github.com/pydantic/pydantic-ai/tree/main/src/pydantic_ai_harness/pydantic_ai_harness/refine_output/]. That link does not establish licensing terms; the applicable license files would need separate examination.
Version and freshness
The page was captured on 15 November 2026 at 14:09:45.068 UTC. This capture time does not establish the page's publication date or the package's latest release.
The documentation warns that Pydantic AI Harness APIs can change between minor releases while on 0.x versions, with deprecation warnings and release-note migration guidance accompanying changes. The exact package version represented by this page and its compatibility with an existing project are unknown.
Suggested next steps
Before integrating the feature, confirm the API for the package version you intend to use, configure provider access and set an appropriate request budget through UsageLimits. Check the applicable license terms if licensing affects adoption or redistribution.
Evaluate representative tasks with known reference answers, comparing initial and revised outputs while recording request counts, elapsed time and errors. Start with one review round and add rounds only if observed benefits justify the extra usage.
Keep output callbacks free of side effects, account for run types that skip review, and choose Agent.run() with an event_stream_handler or Agent.iter() if streaming must include refinement.
