Skip to content

Commit f24739b

Browse files
authored
Merge branch 'main' into snake-case-field
2 parents fd7dd8c + 73c2e6f commit f24739b

File tree

9 files changed

+492
-406
lines changed

9 files changed

+492
-406
lines changed

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
run: |
5656
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
5757
- name: Install dependencies
58-
run: uv sync --dev --extra sql --extra encryption
58+
run: uv sync --dev --extra sql --extra encryption --extra grpc
5959
- name: Run tests and check coverage
6060
run: uv run pytest --cov=a2a --cov-report=xml --cov-fail-under=89
6161
- name: Show coverage summary in log

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [0.2.14](https://github.com/a2aproject/a2a-python/compare/v0.2.13...v0.2.14) (2025-07-18)
4+
5+
6+
### Features
7+
8+
* Set grpc dependencies as optional ([#322](https://github.com/a2aproject/a2a-python/issues/322)) ([365f158](https://github.com/a2aproject/a2a-python/commit/365f158f87166838b55bdadd48778cb313a453e1))
9+
* **spec:** Update A2A types from specification 🤖 ([#325](https://github.com/a2aproject/a2a-python/issues/325)) ([02e7a31](https://github.com/a2aproject/a2a-python/commit/02e7a3100e000e115b4aeec7147cf8fc1948c107))
10+
311
## [0.2.13](https://github.com/a2aproject/a2a-python/compare/v0.2.12...v0.2.13) (2025-07-17)
412

513

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<h2 align="center">
1212
<img src="https://raw.githubusercontent.com/a2aproject/A2A/refs/heads/main/docs/assets/a2a-logo-black.svg" width="256" alt="A2A Logo"/>
1313
</h2>
14-
<h3 align="center">A Python library that helps run agentic applications as A2AServers following the <a href="https://a2aproject.github.io/A2A">Agent2Agent (A2A) Protocol</a>.</h3>
14+
<h3 align="center">A Python library that helps run agentic applications as A2AServers following the <a href="https://a2a-protocol.org">Agent2Agent (A2A) Protocol</a>.</h3>
1515
</html>
1616

1717
<!-- markdownlint-enable no-inline-html -->
@@ -33,6 +33,12 @@ When you're working within a uv project or a virtual environment managed by uv,
3333
uv add a2a-sdk
3434
```
3535

36+
To install with gRPC support:
37+
38+
```bash
39+
uv add "a2a-sdk[grpc]"
40+
```
41+
3642
To install with database support:
3743

3844
```bash
@@ -57,6 +63,12 @@ If you prefer to use pip, the standard Python package installer, you can install
5763
pip install a2a-sdk
5864
```
5965

66+
To install with gRPC support:
67+
68+
```bash
69+
pip install "a2a-sdk[grpc]"
70+
```
71+
6072
To install with database support:
6173

6274
```bash

pyproject.toml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@ dependencies = [
1111
"fastapi>=0.115.2",
1212
"httpx>=0.28.1",
1313
"httpx-sse>=0.4.0",
14-
"google-api-core>=1.26.0",
1514
"opentelemetry-api>=1.33.0",
1615
"opentelemetry-sdk>=1.33.0",
1716
"pydantic>=2.11.3",
1817
"sse-starlette",
19-
"starlette",
20-
"grpcio>=1.60",
21-
"grpcio-tools>=1.60",
22-
"grpcio_reflection>=1.7.0",
23-
"protobuf==5.29.5",
18+
"starlette"
2419
]
2520

2621
classifiers = [
@@ -42,6 +37,7 @@ mysql = ["sqlalchemy[asyncio,aiomysql]>=2.0.0"]
4237
sqlite = ["sqlalchemy[asyncio,aiosqlite]>=2.0.0"]
4338
sql = ["sqlalchemy[asyncio,postgresql-asyncpg,aiomysql,aiosqlite]>=2.0.0"]
4439
encryption = ["cryptography>=43.0.0"]
40+
grpc = ["grpcio>=1.60", "grpcio-tools>=1.60", "grpcio_reflection>=1.7.0", "protobuf==5.29.5", "google-api-core>=1.26.0"]
4541

4642
[project.urls]
4743
homepage = "https://a2aproject.github.io/A2A/"

src/a2a/server/request_handlers/__init__.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""Request handler components for the A2A server."""
22

3+
import logging
4+
35
from a2a.server.request_handlers.default_request_handler import (
46
DefaultRequestHandler,
57
)
6-
from a2a.server.request_handlers.grpc_handler import GrpcHandler
78
from a2a.server.request_handlers.jsonrpc_handler import JSONRPCHandler
89
from a2a.server.request_handlers.request_handler import RequestHandler
910
from a2a.server.request_handlers.response_helpers import (
@@ -12,6 +13,28 @@
1213
)
1314

1415

16+
logger = logging.getLogger(__name__)
17+
18+
try:
19+
from a2a.server.request_handlers.grpc_handler import (
20+
GrpcHandler, # type: ignore
21+
)
22+
except ImportError as e:
23+
_original_error = e
24+
logger.debug(
25+
'GrpcHandler not loaded. This is expected if gRPC dependencies are not installed. Error: %s',
26+
)
27+
28+
class GrpcHandler: # type: ignore
29+
"""Placeholder for GrpcHandler when dependencies are not installed."""
30+
31+
def __init__(self, *args, **kwargs):
32+
raise ImportError(
33+
'To use GrpcHandler, its dependencies must be installed. '
34+
'You can install them with \'pip install "a2a-sdk[grpc]"\''
35+
) from _original_error
36+
37+
1538
__all__ = [
1639
'DefaultRequestHandler',
1740
'GrpcHandler',

src/a2a/server/request_handlers/grpc_handler.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@
55
from abc import ABC, abstractmethod
66
from collections.abc import AsyncIterable
77

8-
import grpc
9-
import grpc.aio
8+
9+
try:
10+
import grpc
11+
import grpc.aio
12+
except ImportError as e:
13+
raise ImportError(
14+
'GrpcHandler requires grpcio and grpcio-tools to be installed. '
15+
'Install with: '
16+
"'pip install a2a-sdk[grpc]'"
17+
) from e
1018

1119
import a2a.grpc.a2a_pb2_grpc as a2a_grpc
1220

0 commit comments

Comments
 (0)