Skip to content

Commit fc1ac9a

Browse files
committed
Merge branch 'main' into make-fastapi-package-optional
2 parents 3e85414 + dc95e2a commit fc1ac9a

File tree

9 files changed

+312
-259
lines changed

9 files changed

+312
-259
lines changed

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Set postgres for tests
3535
run: |
3636
sudo apt-get update && sudo apt-get install -y postgresql-client
37-
PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d a2a_test -f ${{ github.workspace }}/docker/postgres/init.sql
37+
PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d a2a_test -f ${{ github.workspace }}/tests/docker/postgres/init.sql
3838
export POSTGRES_TEST_DSN="postgresql+asyncpg://postgres:postgres@localhost:5432/a2a_test"
3939
4040
- name: Install uv

CHANGELOG.md

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

3+
## [0.2.12](https://github.com/a2aproject/a2a-python/compare/v0.2.11...v0.2.12) (2025-07-14)
4+
5+
6+
### Features
7+
8+
* add `metadata` property to `RequestContext` ([#302](https://github.com/a2aproject/a2a-python/issues/302)) ([e781ced](https://github.com/a2aproject/a2a-python/commit/e781ced3b082ef085f9aeef02ceebb9b35c68280))
9+
* add A2ABaseModel ([#292](https://github.com/a2aproject/a2a-python/issues/292)) ([24f2eb0](https://github.com/a2aproject/a2a-python/commit/24f2eb0947112539cbd4e493c98d0d9dadc87f05))
10+
* add support for notification tokens in PushNotificationSender ([#266](https://github.com/a2aproject/a2a-python/issues/266)) ([75aa4ed](https://github.com/a2aproject/a2a-python/commit/75aa4ed866a6b4005e59eb000e965fb593e0888f))
11+
* Update A2A types from specification 🤖 ([#289](https://github.com/a2aproject/a2a-python/issues/289)) ([ecb321a](https://github.com/a2aproject/a2a-python/commit/ecb321a354d691ca90b52cc39e0a397a576fd7d7))
12+
13+
14+
### Bug Fixes
15+
16+
* add proper a2a request body documentation to Swagger UI ([#276](https://github.com/a2aproject/a2a-python/issues/276)) ([4343be9](https://github.com/a2aproject/a2a-python/commit/4343be99ad0df5eb6908867b71d55b1f7d0fafc6)), closes [#274](https://github.com/a2aproject/a2a-python/issues/274)
17+
* Handle asyncio.cancellederror and raise to propagate back ([#293](https://github.com/a2aproject/a2a-python/issues/293)) ([9d6cb68](https://github.com/a2aproject/a2a-python/commit/9d6cb68a1619960b9c9fd8e7aa08ffb27047343f))
18+
* Improve error handling in task creation ([#294](https://github.com/a2aproject/a2a-python/issues/294)) ([6412c75](https://github.com/a2aproject/a2a-python/commit/6412c75413e26489bd3d33f59e41b626a71807d3))
19+
* Resolve dependency issue with sql stores ([#303](https://github.com/a2aproject/a2a-python/issues/303)) ([2126828](https://github.com/a2aproject/a2a-python/commit/2126828b5cb6291f47ca15d56c0e870950f17536))
20+
* Send push notifications for message/send ([#298](https://github.com/a2aproject/a2a-python/issues/298)) ([0274112](https://github.com/a2aproject/a2a-python/commit/0274112bb5b077c17b344da3a65277f2ad67d38f))
21+
* **server:** Improve event consumer error handling ([#282](https://github.com/a2aproject/a2a-python/issues/282)) ([a5786a1](https://github.com/a2aproject/a2a-python/commit/a5786a112779a21819d28e4dfee40fa11f1bb49a))
22+
323
## [0.2.11](https://github.com/a2aproject/a2a-python/compare/v0.2.10...v0.2.11) (2025-07-07)
424

525

src/a2a/server/agent_execution/context.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import uuid
22

3+
from typing import Any
4+
35
from a2a.server.context import ServerCallContext
46
from a2a.types import (
57
InvalidParamsError,
@@ -134,6 +136,13 @@ def call_context(self) -> ServerCallContext | None:
134136
"""The server call context associated with this request."""
135137
return self._call_context
136138

139+
@property
140+
def metadata(self) -> dict[str, Any]:
141+
"""Metadata associated with the request, if available."""
142+
if not self._params:
143+
return {}
144+
return self._params.metadata or {}
145+
137146
def _check_or_generate_task_id(self) -> None:
138147
"""Ensures a task ID is present, generating one if necessary."""
139148
if not self._params:

src/a2a/server/tasks/__init__.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""Components for managing tasks within the A2A server."""
22

3+
import logging
4+
35
from a2a.server.tasks.base_push_notification_sender import (
46
BasePushNotificationSender,
57
)
6-
from a2a.server.tasks.database_task_store import DatabaseTaskStore
78
from a2a.server.tasks.inmemory_push_notification_config_store import (
89
InMemoryPushNotificationConfigStore,
910
)
@@ -18,6 +19,30 @@
1819
from a2a.server.tasks.task_updater import TaskUpdater
1920

2021

22+
logger = logging.getLogger(__name__)
23+
24+
try:
25+
from a2a.server.tasks.database_task_store import (
26+
DatabaseTaskStore, # type: ignore
27+
)
28+
except ImportError as e:
29+
_original_error = e
30+
# If the database task store is not available, we can still use in-memory stores.
31+
logger.debug(
32+
'DatabaseTaskStore not loaded. This is expected if database dependencies are not installed. Error: %s',
33+
e,
34+
)
35+
36+
class DatabaseTaskStore: # type: ignore
37+
"""Placeholder for DatabaseTaskStore when dependencies are not installed."""
38+
39+
def __init__(self, *args, **kwargs):
40+
raise ImportError(
41+
'To use DatabaseTaskStore, its dependencies must be installed. '
42+
'You can install them with \'pip install "a2a-sdk[sql]"\''
43+
) from _original_error
44+
45+
2146
__all__ = [
2247
'BasePushNotificationSender',
2348
'DatabaseTaskStore',

src/a2a/utils/task.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ def new_task(request: Message) -> Task:
1515
1616
Returns:
1717
A new `Task` object initialized with 'submitted' status and the input message in history.
18+
19+
Raises:
20+
TypeError: If the message role is None.
21+
ValueError: If the message parts are empty.
1822
"""
23+
if not request.role:
24+
raise TypeError('Message role cannot be None')
25+
if not request.parts:
26+
raise ValueError('Message parts cannot be empty')
27+
1928
return Task(
2029
status=TaskStatus(state=TaskState.submitted),
2130
id=(request.taskId if request.taskId else str(uuid.uuid4())),

0 commit comments

Comments
 (0)