|
3 | 3 | from collections.abc import AsyncIterable
|
4 | 4 |
|
5 | 5 | from a2a.server.request_handlers.request_handler import RequestHandler
|
6 |
| -from a2a.server.request_handlers.response_helpers import ( |
7 |
| - prepare_response_object, |
8 |
| -) |
| 6 | +from a2a.server.request_handlers.response_helpers import prepare_response_object |
9 | 7 | from a2a.types import (
|
10 | 8 | AgentCard,
|
11 | 9 | CancelTaskRequest,
|
|
37 | 35 | TaskStatusUpdateEvent,
|
38 | 36 | )
|
39 | 37 | from a2a.utils.errors import ServerError
|
| 38 | +from a2a.utils.helpers import validate |
40 | 39 |
|
41 | 40 |
|
42 | 41 | logger = logging.getLogger(__name__)
|
@@ -83,6 +82,10 @@ async def on_message_send(
|
83 | 82 | )
|
84 | 83 |
|
85 | 84 | # message/stream
|
| 85 | + @validate( |
| 86 | + lambda self: self.agent_card.capabilities.streaming, |
| 87 | + 'Streaming is not supported by the agent', |
| 88 | + ) |
86 | 89 | async def on_message_send_stream(
|
87 | 90 | self, request: SendStreamingMessageRequest
|
88 | 91 | ) -> AsyncIterable[SendStreamingMessageResponse]:
|
@@ -183,6 +186,10 @@ async def get_push_notification(
|
183 | 186 | )
|
184 | 187 |
|
185 | 188 | # tasks/pushNotification/set
|
| 189 | + @validate( |
| 190 | + lambda self: self.agent_card.capabilities.pushNotifications, |
| 191 | + 'Push notifications are not supported by the agent', |
| 192 | + ) |
186 | 193 | async def set_push_notification(
|
187 | 194 | self, request: SetTaskPushNotificationConfigRequest
|
188 | 195 | ) -> SetTaskPushNotificationConfigResponse:
|
|
0 commit comments