Skip to content

Port pydantic-ai's A2A integration tests + wire CI to run them#57

Merged
dsfaccini merged 3 commits into
datalayer:release/0.6from
dsfaccini:pydantic-ai-bridge-tests
May 21, 2026
Merged

Port pydantic-ai's A2A integration tests + wire CI to run them#57
dsfaccini merged 3 commits into
datalayer:release/0.6from
dsfaccini:pydantic-ai-bridge-tests

Conversation

@dsfaccini
Copy link
Copy Markdown
Collaborator

Summary

Brings the A2A integration tests over from pydantic/pydantic-ai's tests/test_a2a.py so the fasta2a.pydantic_ai bridge has real CI coverage upstream. After this lands, pydantic-ai can safely drop its in-tree tests/test_a2a.py in the v2-exec PR (companion: pydantic/pydantic-ai#5426 merged 2026-05-15, follow-up v2-exec PR pending).

What's covered

tests/test_pydantic_ai.py (11 tests, ported verbatim — snapshots transferred unchanged because the bridge code is identical):

  • Pydantic model output with JSON schema metadata
  • Lifespan-required runtime error
  • Text / file-URI / file-bytes / data Part round-trips
  • Error handling (worker raises → task state='failed')
  • Multi-task context sharing (context_id accumulates message history)
  • Thinking-response serialization
  • History splicing before worker pickup
  • Multi-message conversations across tasks/send

CI changes

.github/workflows/main.yml:

  • Trigger expanded to release/** branches (so this branch's CI fires)
  • Install step adds --extra pydantic-ai; the extra is marker-gated to Python 3.10+, so on the 3.9 matrix row it resolves to nothing and the test file short-circuits via pytest.importorskip('pydantic_ai')

Dev deps

  • anyio (explicit; previously transitive)
  • dirty-equals (for IsStr / IsDatetime / IsNow matchers used in inline-snapshot snapshots)
  • tests/assets/kiwi.jpg for the file-content test (~100KB)

Verification

scripts/check clean (ruff format/check, pyright 0/0/0 with file-level reportUnknownVariableType / reportUnknownArgumentType suppression — the bridge raises ImportError when pydantic-ai is missing so pyright sees an Unknown branch on every call); scripts/test 16/16 pass (5 existing + 11 new); coverage on fasta2a/pydantic_ai/_bridge.py jumps from 0% to 89%.

Adds `tests/test_pydantic_ai.py` (11 tests) covering the `fasta2a.pydantic_ai`
bridge end-to-end: pydantic model outputs with JSON schema, lifespan
required-or-runtime-error, text/file/data Part round-trips, error handling,
multi-task context sharing, thinking responses, history splicing, and
multi-message conversations. Ported verbatim from `tests/test_a2a.py` in
`pydantic/pydantic-ai`; snapshots transferred unchanged because the bridge
code is identical.

CI:
- `main.yml` now triggers on `release/**` branches too (not just `main`)
- Install step adds `--extra pydantic-ai`; the extra is marker-gated to
  Python 3.10+, so on 3.9 it resolves to nothing and the test file
  short-circuits via `pytest.importorskip('pydantic_ai')`

Dev deps:
- Added `anyio` (explicit), `dirty-equals` (matchers in snapshots)
- Added `tests/assets/kiwi.jpg` (copied from pydantic-ai test assets)

After this, `pydantic-ai`'s in-tree `tests/test_a2a.py` can be safely
dropped in the v2-exec PR since the same coverage now lives upstream.
@echarles
Copy link
Copy Markdown
Member

Thx @dsfaccini for opening this, that will help to have better coverage indeed

CI is failing with lint errors https://github.com/datalayer/fasta2a/actions/runs/25979237907/job/76911386271?pr=57

   |
help: Remove unused `noqa` directive

Found 9 errors.
[*] 9 fixable with the `--fix` option.
Error: Process completed with exit code 1.

dsfaccini and others added 2 commits May 21, 2026 13:45
ruff doesn't raise E402 on imports following the importorskip/TYPE_CHECKING
preamble, so RUF100 flagged the suppressions as dead.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
scripts/check runs pyright, which must resolve the bridge's pydantic_ai
imports. pydantic-ai-slim is marker-gated to Python 3.10+, so running the
check across the test matrix failed on the 3.9 row where the extra resolves
to nothing. The new lint job pins 3.12; the test matrix now runs only
scripts/test.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dsfaccini
Copy link
Copy Markdown
Collaborator Author

hey @echarles sorry I was working on pydantic-ai v2 for the past week, so just got back to this. gonna merge this one, then update the PR I have against main

@dsfaccini dsfaccini merged commit 48d9e1a into datalayer:release/0.6 May 21, 2026
7 checks passed
@echarles
Copy link
Copy Markdown
Member

Tx @dsfaccini - what is the goal of the release/0.6 branch vs the main branch?

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.

2 participants