2929from a2a .server .request_handlers .request_handler import RequestHandler
3030from a2a .types .a2a_pb2 import AgentCard
3131from a2a .utils .errors import A2AError , InvalidParamsError
32- from a2a .utils .helpers import maybe_await
32+ from a2a .utils .helpers import maybe_await , validate , validate_async_generator
3333
3434
3535logger = logging .getLogger (__name__ )
@@ -170,6 +170,10 @@ async def _handler(
170170 context , _handler , a2a_v0_3_pb2 .SendMessageResponse ()
171171 )
172172
173+ @validate_async_generator (
174+ lambda self : self .agent_card .capabilities .streaming ,
175+ 'Streaming is not supported by the agent' ,
176+ )
173177 async def SendStreamingMessage (
174178 self ,
175179 request : a2a_v0_3_pb2 .SendMessageRequest ,
@@ -229,6 +233,10 @@ async def _handler(
229233
230234 return await self ._handle_unary (context , _handler , a2a_v0_3_pb2 .Task ())
231235
236+ @validate_async_generator (
237+ lambda self : self .agent_card .capabilities .streaming ,
238+ 'Streaming is not supported by the agent' ,
239+ )
232240 async def TaskSubscription (
233241 self ,
234242 request : a2a_v0_3_pb2 .TaskSubscriptionRequest ,
@@ -252,6 +260,10 @@ async def _handler(
252260 async for item in self ._handle_stream (context , _handler ):
253261 yield item
254262
263+ @validate (
264+ lambda self : self .agent_card .capabilities .push_notifications ,
265+ 'Push notifications are not supported by the agent' ,
266+ )
255267 async def CreateTaskPushNotificationConfig (
256268 self ,
257269 request : a2a_v0_3_pb2 .CreateTaskPushNotificationConfigRequest ,
0 commit comments