Skip to content

Add pydantic_ai bridge submodule (port from pydantic-ai _a2a.py)#55

Draft
dsfaccini wants to merge 2 commits intodatalayer:mainfrom
dsfaccini:add-pydantic-ai-bridge
Draft

Add pydantic_ai bridge submodule (port from pydantic-ai _a2a.py)#55
dsfaccini wants to merge 2 commits intodatalayer:mainfrom
dsfaccini:add-pydantic-ai-bridge

Conversation

@dsfaccini
Copy link
Copy Markdown

@dsfaccini dsfaccini commented May 8, 2026

Claude here:

Port of pydantic-ai's Agent.to_a2a() integration into this package, in advance of the v2 deprecation on the pydantic-ai side (see pydantic/pydantic-ai card 46).

Why now

After the FastA2A donation, pydantic-ai is deprecating Agent.to_a2a(), the pydantic_ai._a2a module, and the a2a install extra in 1.x — to be removed in v2. Users who hit those deprecation warnings need somewhere to land. This PR brings the bridge code into the FastA2A repo so the migration message can simply be 'install fasta2a[pydantic-ai] and import agent_to_a2a'.

What's in the diff

  • fasta2a/pydantic_ai/__init__.py — re-exports agent_to_a2a, AgentWorker, worker_lifespan
  • fasta2a/pydantic_ai/_bridge.py — 1-to-1 port of pydantic_ai._a2a (~241 lines). Imports flipped: this submodule imports from pydantic_ai, not the other way around. The body is unchanged so you can see exactly what shipped today.
  • pyproject.toml — adds pydantic-ai = ['pydantic-ai-slim>=1.92'] optional extra. Pinned to slim to avoid pulling the full LLM-provider matrix into anyone who installs fasta2a[pydantic-ai].

Open for redirection — happy to iterate

This is intentionally a near-verbatim port so you can pick the API shape:

  1. API shape: flat agent_to_a2a() function (current) vs. an AgentApplication class? Module layout fasta2a.pydantic_ai (current) vs. fasta2a.bridges.pydantic_ai if you anticipate more bridges?
  2. Optional dep target: pydantic-ai-slim>=1.92 or the full pydantic-ai? Slim is the conservative pick.
  3. Tests: not ported. The pydantic-ai side has 1033 lines of A2A tests in tests/test_a2a.py; happy to port subset, or leave to you to test in your style.
  4. README: not touched. Suggested snippet in the card-46 plan doc if useful.

Sequencing

Marking this PR as draft because the pydantic-ai-side deprecation PR (a v2:prep PR adding @deprecated warnings on Agent.to_a2a() etc.) is held until this one lands or has a confirmed merge ETA — the deprecation message will point users here.

Reach out on the donation Slack channel or here — happy to update or hand the PR off.

cc @Kludex

dsfaccini added 2 commits May 8, 2026 16:35
Port of pydantic-ai's `Agent.to_a2a()` integration into this package, in
advance of the v2 deprecation on the pydantic-ai side. This is a near-verbatim
port of `pydantic_ai_slim/pydantic_ai/_a2a.py` so the API can be redesigned
in-tree if the maintainers prefer a different shape.
The previous >=0.5 floor was a typo from copying the plan-doc — pydantic-ai is
on v1.92.0 and the bridge depends on symbols (AbstractAgent, BinaryContent,
VideoUrl, …) that don't exist below 1.x.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant