In short.
Pydantic AI's Agent Specs guide helps developers and configuration authors move agent definitions into YAML or JSON, but those definitions must be trusted like application code. It explains file loading, configuration overrides, dependency templates, supported capabilities and saving specs with editor schemas. Two validation limits matter: deps_schema checks template variable names rather than runtime dependency values, and output_schema does not enforce output properties or required fields. Installation requirements, release compatibility, costs and licences are not established by this page. No examples were executed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage is the complete supplied page at [https://pydantic.dev/docs/ai/core-concepts/agent-spec/index.md], including its documentation-index and query-parameter notices, examples, capability syntax, AgentSpec reference, saving instructions, trust warning and validation caveats. Linked pages, package source and external services are excluded. No installation, code execution, network connection, model call, benchmark or runtime validation was performed.
The overview
Identity
This is Pydantic AI documentation for Agent Specs, a declarative way to describe agent configuration in YAML or JSON. A spec can select a model, supply instructions and settings, and declare capabilities; Python loads that configuration to construct an agent.
The source is the complete Agent Specs page at [https://pydantic.dev/docs/ai/core-concepts/agent-spec/index.md]. It is a feature guide and reference, rather than a standalone agent application or a ready-made agent definition.
Assessment
The guide is useful when teams want agent instructions and supported settings to live alongside other configuration files. It gives concrete loading examples and explains how configuration interacts with Python arguments, which helps prevent mistaken assumptions about overrides.
Its practical limits concern trust and validation. A spec can choose network-connected capabilities, including endpoints on localhost or private networks. Schema declarations also provide narrower guarantees than their names might suggest. The page documents these limits explicitly; operational reliability and performance are not assessed.
Users
Developers maintaining Pydantic AI applications can use this guide to separate agent configuration from application logic. Prompt engineers and domain experts can use the resulting files to edit instructions and supported capabilities, with a Python application providing the loading and runtime integration.
Beginners receive short examples of YAML configuration and Python loading. Experienced developers get the more consequential details: override precedence, dependency-template checks, serialization limits and capability authorization. A complete installation-to-deployment tutorial is not provided.
Capabilities
Agent.from_file loads YAML or JSON, while Agent.from_spec accepts a dictionary or AgentSpec instance. AgentSpec can also be loaded separately for inspection and saved back to a file.
Declarable capabilities include thinking, caching, instrumentation, web search and fetching, image generation, MCP connections, workspaces, model fallback, retries on model errors and batch requests. Custom capabilities can support specs, but their implementation is described on a linked page outside this material.
Other configurable fields include retry budgets, stopping strategy, default tool timeout, metadata and Logfire instrumentation. AgentSpec.to_file can generate a companion JSON Schema for completion and validation in editors supporting the YAML Language Server protocol.
Using it
Requirements
The examples require a Python application able to import Agent or AgentSpec from pydantic_ai. Configuration can come from a YAML or JSON file, a dictionary or an AgentSpec instance. A model can be specified in the spec, supplied during construction or supplied when running the agent.
Templates obtain values from the runtime deps object, meaning application-supplied context. A Python deps_type or a deps_schema enables construction-time checks of template variable names.
The page does not establish installation commands, minimum Python version, compatible Pydantic AI releases, provider authentication setup or optional capability dependencies.
Mechanism
AgentSpec represents configuration as structured fields. Capability declarations accept a name with no arguments, a name paired with one positional value, or a name paired with keyword arguments. A mapping with string keys is interpreted as keyword arguments.
In Agent.from_spec, supplied scalar arguments override spec values, including retries. Instructions and capabilities are combined with spec entries first. Model settings are merged, with Python arguments winning for matching keys. A supplied output_type takes precedence over output_schema.
Strings containing {{ become templates. Template variables are resolved from deps at runtime; instructions, descriptions and capability arguments can be checked against deps_type during construction. deps_schema checks variable names against schema properties without validating the actual runtime deps object.
output_schema creates a StructuredDict output type and sends the schema to the model API. The result is returned as a dictionary without validating its properties or required fields against that schema.
Setup
In an existing Pydantic AI application, place the desired configuration in agent.yaml or a JSON file. The documented loading pattern imports Agent from pydantic_ai and calls Agent.from_file('agent.yaml') to construct the agent.
Use Agent.from_spec when application code needs to supplement configuration, provide deps_type or override fields. Use AgentSpec.from_file first when the configuration needs inspection before agent construction.
To save a definition, create an AgentSpec and call spec.to_file('agent.yaml'). The example also generates agent_schema.json for editor assistance; schema_path=None disables that companion schema. These are documented steps and were not executed.
Example
The research-assistant YAML example sets a model, instructions and max_tokens of 8192, then declares WebSearch with local: duckduckgo and Thinking with effort: high. It illustrates configuring those features without writing Python agent-construction arguments for each field; no behavior or cost was measured.
A separate Python example supplies instructions containing {{user_name}} and passes a UserContext dataclass as deps_type to Agent.from_spec. The template name can therefore be checked against the declared context fields during construction.
The output-schema example declares answer and confidence as required properties. The page explicitly warns that those declarations are not runtime validation constraints, so an application cannot infer that both fields are present and correctly typed merely from this configuration.
Assessment & evidence
Limitations
Specs have the same authority as agent-construction code. An MCP capability can connect to the specified server using the host machine's network access, including localhost and private addresses. The guide advises trusting spec sources and checking every capability name and its arguments against the submitting user's permissions before construction.
Capabilities requiring non-serializable values, such as callables or toolset objects, require Python code. Declarative specs therefore cover only capabilities that support their serialization format.
deps_schema does not validate runtime context values, and output_schema does not validate output properties or required fields. Editor validation of a configuration file is a separate concern from validation of an agent's runtime inputs and results.
The page provides no benchmark results, deployment evidence or compatibility matrix. Model-specific capability availability and actual runtime behavior were not assessed.
Reasoning
The documented separation of configuration from code supports sharing definitions and letting domain experts edit agent behavior. A reasonable fit is an application where frequently edited instructions and supported settings can be serialized, while developers retain Python integration.
That benefit depends on understanding the boundaries. Moving configuration into a file preserves its authority over models, instructions and capabilities. Likewise, adding JSON Schema can guide editing or model output without establishing validation of runtime values. These are design implications of the documented behavior, rather than measured outcomes.
Alternatives
The page also shows direct construction with Agent in Python. This accommodates capabilities requiring Python objects. For dynamic instructions in Python, it generally prefers a callable using RunContext over TemplateStr because of IDE completion and type checking.
Agent.from_spec with an in-memory dictionary offers another documented approach when application code should assemble configuration without a separate file. No evidence comparing other frameworks, their costs or their performance is supplied.
Evidence
The evidence is the complete documentation page at [https://pydantic.dev/docs/ai/core-concepts/agent-spec/index.md]. It includes explanatory text, YAML and Python examples, capability syntax, the AgentSpec field reference and explicit trust and validation warnings.
The examples establish documented usage patterns. None were executed, and the page supplies no independent measurements of correctness, latency, reliability or operating cost. Linked documentation and implementation source are outside the assessed material.
Access & freshness
Costs
The page supplies no software pricing, subscription terms, model-provider rates or worked usage costs. Total cost is unknown.
Model selection, tool use, retry budgets, fallback and batch settings are relevant to a deployment cost assessment, but this page does not quantify their effects. It establishes no savings from caching or batching.
Rights
The page does not state a software licence, documentation licence, redistribution permission or model-provider terms. Those rights remain unknown from this source.
Freshness
The documentation snapshot was captured at 2026-11-23T09:42:19.148Z. Its source SHA-256 is 64f4005bdbed5b139999073a4be8d0894bb9f35665f36c566c115bf031cf432d.
The page supplies no Pydantic AI release number, publication date or last-updated date. Compatibility with a particular installed release and changes after capture are unknown.
Actions
Identify which instructions, settings and capabilities should live in configuration and which require Python objects. Confirm that the installed Pydantic AI release supports the documented APIs, then verify loading and override behavior in a development environment.
For user-supplied specs, inspect AgentSpec before constructing an agent and authorize capability names, arguments and network destinations. Where application correctness depends on context values or output fields, add explicit runtime validation rather than relying on deps_schema or output_schema alone.
Confirm installation requirements, provider access, capability dependencies, costs and applicable rights before adoption. This page does not establish those details.
