Add spec_file support to PydanticAIHook.create_agent#67788
Open
gopidesupavan wants to merge 4 commits into
Open
Add spec_file support to PydanticAIHook.create_agent#67788gopidesupavan wants to merge 4 commits into
gopidesupavan wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a spec_file parameter to PydanticAIHook.create_agent, allowing agent configuration (model, instructions, model_settings, retries, etc.) to be loaded from a pydantic-ai YAML/JSON AgentSpec file via Agent.from_file(...) instead of being hard-coded in Python. Also bumps the pydantic-ai-slim minimum to >=1.72.0 (which introduced from_file) and adds docs plus an example DAG + example YAML spec.
Changes:
- Add
spec_fileparameter and new overloads toPydanticAIHook.create_agent; raiseValueErrorwhen neitherinstructionsnorspec_fileis given. - Add docs section, example DAG, and example YAML spec for the new spec-file workflow.
- Bump
pydantic-ai-slimminimum to>=1.72.0inpyproject.toml, README, docs index, anduv.lock.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| providers/common/ai/src/airflow/providers/common/ai/hooks/pydantic_ai.py | New spec_file branch in create_agent delegating to Agent.from_file with overloads. |
| providers/common/ai/tests/unit/common/ai/hooks/test_pydantic_ai.py | Adds tests for spec_file routing, Path support, instruction override, output_type, kwargs forwarding, and validation error. |
| providers/common/ai/src/airflow/providers/common/ai/example_dags/example_pydantic_ai_hook.py | New example DAG demonstrating spec_file use and instruction override. |
| providers/common/ai/src/airflow/providers/common/ai/example_dags/example_agent_spec.yaml | New example AgentSpec YAML file used by the example DAG. |
| providers/common/ai/docs/hooks/pydantic_ai.rst | New "Loading Agent Config from a Spec File" docs section with YAML sample and example include. |
| providers/common/ai/pyproject.toml | Bump pydantic-ai-slim minimum to >=1.72.0. |
| providers/common/ai/README.rst | Reflect bumped pydantic-ai-slim version. |
| providers/common/ai/docs/index.rst | Reflect bumped pydantic-ai-slim version. |
| uv.lock | Lockfile update for the bumped pydantic-ai-slim minimum. |
kaxil
reviewed
May 30, 2026
kaxil
approved these changes
May 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
spec_fileparameter toPydanticAIHook.create_agentto loadagent settings from a pydantic-ai
AgentSpecYAML or JSON file insteadof hard-coding them in Python.
https://pydantic.dev/docs/ai/core-concepts/agent-spec/#loading-specs
Was generative AI tooling used to co-author this PR?
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.