PydanticAIDocs: {} in a Pydantic AI YAML spec is not self-contained: the documented loader uses Agent.from_file(..., custom_capability_types=[PydanticAIDocs]), and the capability is imported from pydantic_ai_harness. A reviewer who approves only the declarative diff therefore has not checked the registration, package dependency, or documentation source on which the agent depends, according to Pydantic’s PydanticAIDocs reference.
Treat a spec-only diff as incomplete, not automatically defective. The registration and documentation configuration may already exist elsewhere in the repository. If they do, the review should identify and exercise that existing path. If they do not, they need to ship with the spec change. The merge decision should also account for the PyaiDocs rename and the harness’s 0.x upgrade policy.
The spec is an instruction to code, not the code itself
Pydantic’s documented example is deliberately small:
model: anthropic:claude-sonnet-5-5capabilities: - PydanticAIDocs: {}The model line is part of the vendor’s example; the dependency problem comes from the capability entry. PydanticAIDocs gives the agent one tool, read_pyai_docs(topic), which locates a Pydantic AI documentation page and returns it in full. It does not load the documentation into context up front. That makes documentation resolution a runtime behavior to review, rather than content contained in the YAML, as the capability reference describes.
The corresponding Python is outside the spec:
from pydantic_ai import Agentfrom pydantic_ai_harness import PydanticAIDocs
agent = Agent.from_file('agent.yaml', custom_capability_types=[PydanticAIDocs])result = agent.run_sync('...')print(result.output)This complicates the positioning in Pydantic AI’s overview, which says users can “Or skip code entirely with YAML/JSON agent specs.” That may describe how an agent definition is authored, but it cannot establish that a custom capability needs no Python integration. Pydantic’s own loading example requires both an import and a registration argument.
The same overview defines a capability as the reusable unit bundling tools, instructions, hooks, and model settings. Core supplies fundamentals such as MCP and web search, while the Harness supplies the rest. For a reviewer, the useful distinction is straightforward: the YAML selects and configures a capability; it does not contain the capability’s implementation or prove that the application registered it.
Check the serialization name before the YAML syntax
The block name is a serialization identifier, not an arbitrary label. For the current documented capability, that identifier is PydanticAIDocs. A syntactically valid block can still name something different from the classes supplied to the loader.
The rename from PyaiDocs makes this a concrete review case. According to the reference page:
- Specs saved before the rename retain the
PyaiDocsblock name. - To keep loading them, the deprecated
PyaiDocsclass can be passed alongside or instead ofPydanticAIDocs. - That class is imported from
pydantic_ai_harness.docsand emits a deprecation warning. - It preserves the
PyaiDocsserialization name. - Re-saving the spec with
PydanticAIDocsperforms the migration.
This creates two legitimate paths, with different review requirements. A compatibility change can retain the old spec and register the deprecated alias, while recording the warning and migration work. A migration can re-save the block and update the registration together. What deserves a request for changes is a name-only edit that assumes the loader will follow automatically.
A reviewer should also avoid “fixing” an old block without checking every spec that shares the loading path. The documentation supports coordinating the spec and registered classes; it does not establish that unrelated or older specs can be migrated interchangeably.
Registration and package boundaries belong in the same review
For the documented spec path, the loading call needs custom_capability_types=[PydanticAIDocs], or the appropriate deprecated class for an old spec. Agent comes from pydantic_ai, while PydanticAIDocs comes from the separate pydantic_ai_harness package. The deprecated compatibility class has a third import location, pydantic_ai_harness.docs.
That produces three questions more useful than “is the YAML valid?”
- Which file actually loads this spec? Follow the runtime path to
Agent.from_file, rather than stopping at an example or test fixture. - Does that call register the serialization name used by the spec? Include pre-existing registration in the review, but do not assume it from an import elsewhere.
- Will the runtime environment contain the harness package? If the environment does not already provide it, the change needs the appropriate dependency update as well as the import. The supplied documentation does not prescribe a particular installation command or version constraint.
There is an important evidentiary limit here. The fetched passages do not show what happens when a spec names a capability omitted from custom_capability_types. They do not establish a particular exception type or error message. A reviewer should require a load test in the project’s actual environment and record what that version does, rather than writing an assumed Pydantic error into the review or test suite.
Where will read_pyai_docs get its documentation?
A green agent-construction test does not answer this question. Each documentation call resolves its topic through sources configured outside the YAML block.
The documented resolution behavior is:
local_docs_path, typed asPath | Noneand defaulting toNone, selects a documentation checkout inside the run workspace. Relative paths use the workspace working directory.- When
local_docs_pathisNone, resolution falls back to thePYDANTIC_AI_HARNESS_DOCS_PATHenvironment variable. - If no local source resolves the topic, the tool can fetch the page from GitHub. The remote fallback requires network access.
The remote reference adds another version dependency. remote_ref, also defaulting to None, normally uses the installed pydantic_ai release tag, so the fetched pages describe the installed APIs. The documentation gives v2.69.0 as an example, not as a version every project should adopt. A development build without a release tag reads main; setting remote_ref='main' explicitly requests the latest documentation instead.
Neither source is universally preferable. A workspace checkout can suit controlled or offline-oriented work, but the capability never runs git. Someone must update that checkout manually, and a stale checkout can present stale documentation. The installed-tag fallback avoids that particular maintenance task and aims at version-matched documentation, but it introduces a network dependency. Explicitly selecting main changes the version relationship again and should be a deliberate choice, not an incidental upgrade.
A local path also should not be treated as proof that no remote request can occur. The documented behavior still includes fallback when the local source does not resolve a topic. If a run must be network-free, test that requirement directly instead of inferring it from the presence of local_docs_path.
Caching changes call behavior, not provenance. With the default cache=True, each returned document is memoized for one agent run. Caches are isolated per run, so content from one workspace is not reused in another. cache=False re-reads or re-fetches on every call within a run. That setting deserves review when freshness or repeated retrieval matters, but the supplied evidence does not quantify its performance cost.
Harness 0.x makes upgrade notes part of the diff
Pydantic states that while the Harness is on 0.x releases, its API may change between minor releases. Deprecation warnings and release-note migration guidance are intended to explain how to upgrade. Consequently, a harness version change is not just a package-file detail when the same application loads declarative specs.
For an upgrade, review the release notes alongside three artifacts: the spec’s block name, the registered capability classes, and the documentation-source settings. The PyaiDocs alias is one documented migration path, not evidence that every other API will remain stable.
Duplicate-capability behavior also has version history. The current PydanticAIDocs documentation says the capability declares the default id pydantic_ai_docs. Two instances sharing that id become one when their configurations agree. If they differ, building the agent raises UserError. Keeping two instances requires distinct ids and PrefixTools, because both register a tool named read_pyai_docs.
Earlier releases declared no default id: two PydanticAIDocs instances always failed on the tool name when the run started. A review based on memories of that older behavior could now approve or reject the wrong thing. Tests should target the installed harness version rather than a generic assumption about duplicate capabilities.
Failure modes worth a focused test
The documented behavior supports a small, relevant test set:
- Load the exact spec through its real call site. This checks the serialization name and registration together. Do not presume the undocumented missing-registration error.
- Request an unresolvable topic. When neither local nor remote resolution succeeds, the tool returns a descriptive error naming the local path tried and the URL. Check that the application handles that result appropriately.
- Exercise the intended documentation source without network access where that matters. This tests an operational requirement; the documentation does not promise that configuring a local path disables remote fallback.
- Check local-checkout freshness. Since the capability never runs
git, checkout ownership and updates need a repository or deployment procedure. - Build with the intended number of capability instances. Identical instances, conflicting instances, and deliberately distinct prefixed instances have different documented outcomes.
These tests establish behavior in the project’s environment. They do not independently reproduce Pydantic’s implementation across versions, and they should be revisited when the harness or pydantic_ai version changes.
Why this gap is structural, and what the evidence cannot prove
The underlying issue is not peculiar YAML syntax. The Agent Spec paper, discussing its own declarative agent specification rather than Pydantic AI specifically, says the specification describes tools and their attributes, inputs, outputs, and metadata but “does not contain any executable code.” Implementations and registrations therefore have to live somewhere else. That paper supplies a design constraint, not evidence about Pydantic’s runtime errors.
The Spec Growth Engine paper addresses the resulting coordination problem in spec-driven development. It prescribes classifying each change so that a “fixed rule that names exactly which artefacts must move together” is triggered. Applied here, that principle supports a repository rule coupling capability-spec changes to loader registration, package dependencies, documentation provenance, and relevant migration notes. It does not demonstrate that this particular checklist improves delivery outcomes.
The scaffold-audit paper is motivation for examining more than model weights when coding agents change, but it is only a discovery signal for this article. Its diagnostic-feedback comparison was “a small, underpowered null (Cohen’s f=0.10, 11% power),” and it examined an agent critiquing its own output rather than an architecturally separate reviewer reading the same signal. It cannot establish how often registration mistakes occur or whether a second reviewer would catch them.
All the Pydantic behaviors above are vendor-documented rather than independently reproduced in the research packet. There are no independent reports here of custom-capability registration failures, no frequency estimate, and no measured evaluation of this review process. The checklist is an inference from documented mechanics, with its currency bounded by a 0.x product whose API may change between minor releases.
The merge checklist
| Review item | Evidence to require before approval | Decision when it is absent |
|---|---|---|
| Serialization name | The spec uses PydanticAIDocs, or an intentional old PyaiDocs spec is paired with the deprecated compatibility class | Request a coordinated spec and registration change; do not assume a rename is standalone |
| Loader registration | The real Agent.from_file path supplies the appropriate class through custom_capability_types, or an existing covering registration is identified and tested | Treat the spec diff as incomplete |
| Package boundary | Agent and the capability use their documented imports, and the runtime has or receives the necessary harness dependency | Require the dependency and import work with the change |
| Documentation provenance | An explicit choice among a maintained local checkout, the environment-variable path, and the network-dependent GitHub fallback, including the intended remote_ref behavior | Ask for the operational decision and a relevant resolution test |
| Harness version coupling | Release-note and deprecation review for a 0.x upgrade, with duplicate-id behavior checked against the installed version | Do not infer compatibility from an unchanged YAML block |
| Failure handling | Focused coverage for unresolved topics, required offline behavior, stale-checkout ownership, and any intentional duplicate capabilities | Add bounded tests or record the unverified operational risk |
These artifacts do not all need editing in every pull request. Existing, exercised integration is a valid reason not to repeat it. The merge rule is that the review must account for it: approve the capability addition only when the spec and its external code dependencies are shown to agree, and when the team has deliberately accepted how documentation will be found and maintained.
Frequently Asked Questions
What happens if a spec names a capability omitted from custom_capability_types?
The fetched passages do not show what happens when a spec names a capability omitted from custom_capability_types. They do not establish a particular exception type or error message. A reviewer should require a load test in the project’s actual environment and record what that version does, rather than writing an assumed Pydantic error into the review or test suite.
How does the read_pyai_docs tool resolve documentation topics?
local_docs_path, typed asPath | Noneand defaulting toNone, selects a documentation checkout inside the run workspace. Relative paths use the workspace working directory.- When
local_docs_pathisNone, resolution falls back to thePYDANTIC_AI_HARNESS_DOCS_PATHenvironment variable. - If no local source resolves the topic, the tool can fetch the page from GitHub. The remote fallback requires network access.
How should reviewers handle the PyaiDocs to PydanticAIDocs rename?
This creates two legitimate paths, with different review requirements. A compatibility change can retain the old spec and register the deprecated alias, while recording the warning and migration work. A migration can re-save the block and update the registration together. What deserves a request for changes is a name-only edit that assumes the loader will follow automatically.
Join the discussion
Share a useful perspective or ask a question about this article.