Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.cache
.coverage
__pycache__
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ _You can run this example as is with `uvicorn main:app --reload`._
As you see, it's pretty easy from the point of view of the developer using your agentic framework.

> [!NOTE]
> In Pydantic AI 1.x, `Agent.to_a2a()` continues to work but emits a deprecation
> warning pointing here. It will be removed in Pydantic AI v2.
> The bridge requires Pydantic AI 2. `Agent.to_a2a()` was removed there; `agent_to_a2a` is its replacement.

#### Streaming

Expand Down
7 changes: 3 additions & 4 deletions fasta2a/pydantic_ai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""Pydantic AI bridge for FastA2A.

Port of `pydantic_ai._a2a` into the FastA2A package, so users can keep using
`Agent.to_a2a()` after the corresponding wrapper is removed from pydantic-ai
in v2. See https://github.com/pydantic/pydantic-ai for the upstream
deprecation context.
Port of `pydantic_ai._a2a` into the FastA2A package: Pydantic AI 2 removed
`Agent.to_a2a()`, and `agent_to_a2a` here is its replacement. See
https://github.com/pydantic/pydantic-ai for the upstream context.

Usage:

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies = [

[project.optional-dependencies]
logfire = ["logfire>=2.3"]
pydantic-ai = ["pydantic-ai-slim>=1.92; python_version >= '3.10'"]
pydantic-ai = ["pydantic-ai-slim>=2.40.0; python_version >= '3.10'"]

[dependency-groups]
dev = [
Expand Down
7 changes: 6 additions & 1 deletion tests/test_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,12 @@ async def test_tasks_get_is_not_gated_by_required_extensions():


def test_agent_to_a2a_forwards_extensions():
pytest.importorskip('pydantic_ai', reason='pydantic-ai-slim required (Python 3.10+)')
try:
import pydantic_ai # noqa: F401 # pyright: ignore[reportUnusedImport]
except ModuleNotFoundError as e:
if e.name == 'pydantic_ai':
pytest.skip('pydantic-ai-slim required (Python 3.10+)')
raise
from pydantic_ai import Agent
from pydantic_ai.models.test import TestModel

Expand Down
9 changes: 8 additions & 1 deletion tests/test_pydantic_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@
from asgi_lifespan import LifespanManager
from inline_snapshot import snapshot

pytest.importorskip('pydantic_ai', reason='pydantic-ai-slim required (Python 3.10+)')
try:
import pydantic_ai # noqa: F401 # pyright: ignore[reportUnusedImport]
except ModuleNotFoundError as e:
# Skip only when pydantic-ai itself is absent (Python 3.9, where the extra
# does not install); a module missing *under* it is a broken environment.
if e.name == 'pydantic_ai':
pytest.skip('pydantic-ai-slim required (Python 3.10+)', allow_module_level=True)
raise

# `dirty_equals` matchers (`IsStr`, `IsDatetime`, `IsNow`) report `__eq__`-based equivalence but pyright
# can't see they're meant to substitute for `str`/`datetime` in equality contexts. Mirror the stubs trick
Expand Down
9 changes: 8 additions & 1 deletion tests/test_pydantic_ai_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
import pytest
from asgi_lifespan import LifespanManager

pytest.importorskip('pydantic_ai', reason='pydantic-ai-slim required (Python 3.10+)')
try:
import pydantic_ai # noqa: F401 # pyright: ignore[reportUnusedImport]
except ModuleNotFoundError as e:
# Skip only when pydantic-ai itself is absent (Python 3.9, where the extra
# does not install); a module missing *under* it is a broken environment.
if e.name == 'pydantic_ai':
pytest.skip('pydantic-ai-slim required (Python 3.10+)', allow_module_level=True)
raise

from pydantic_ai import Agent, ModelMessage, ModelResponse, TextPart
from pydantic_ai.models.function import AgentInfo, FunctionModel
Expand Down
167 changes: 133 additions & 34 deletions uv.lock

Large diffs are not rendered by default.

Loading