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 , validate , validate_async_generator
32+ from a2a .utils .helpers import maybe_await , validate
3333
3434
3535logger = logging .getLogger (__name__ )
@@ -170,17 +170,17 @@ 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- )
177173 async def SendStreamingMessage (
178174 self ,
179175 request : a2a_v0_3_pb2 .SendMessageRequest ,
180176 context : grpc .aio .ServicerContext ,
181177 ) -> AsyncIterable [a2a_v0_3_pb2 .StreamResponse ]:
182178 """Handles the 'SendStreamingMessage' gRPC method (v0.3)."""
183179
180+ @validate (
181+ lambda _ : self .agent_card .capabilities .streaming ,
182+ 'Streaming is not supported by the agent' ,
183+ )
184184 async def _handler (
185185 server_context : ServerCallContext ,
186186 ) -> AsyncIterable [a2a_v0_3_pb2 .StreamResponse ]:
@@ -233,17 +233,17 @@ async def _handler(
233233
234234 return await self ._handle_unary (context , _handler , a2a_v0_3_pb2 .Task ())
235235
236- @validate_async_generator (
237- lambda self : self .agent_card .capabilities .streaming ,
238- 'Streaming is not supported by the agent' ,
239- )
240236 async def TaskSubscription (
241237 self ,
242238 request : a2a_v0_3_pb2 .TaskSubscriptionRequest ,
243239 context : grpc .aio .ServicerContext ,
244240 ) -> AsyncIterable [a2a_v0_3_pb2 .StreamResponse ]:
245241 """Handles the 'TaskSubscription' gRPC method (v0.3)."""
246242
243+ @validate (
244+ lambda _ : self .agent_card .capabilities .streaming ,
245+ 'Streaming is not supported by the agent' ,
246+ )
247247 async def _handler (
248248 server_context : ServerCallContext ,
249249 ) -> AsyncIterable [a2a_v0_3_pb2 .StreamResponse ]:
@@ -260,17 +260,17 @@ async def _handler(
260260 async for item in self ._handle_stream (context , _handler ):
261261 yield item
262262
263- @validate (
264- lambda self : self .agent_card .capabilities .push_notifications ,
265- 'Push notifications are not supported by the agent' ,
266- )
267263 async def CreateTaskPushNotificationConfig (
268264 self ,
269265 request : a2a_v0_3_pb2 .CreateTaskPushNotificationConfigRequest ,
270266 context : grpc .aio .ServicerContext ,
271267 ) -> a2a_v0_3_pb2 .TaskPushNotificationConfig :
272268 """Handles the 'CreateTaskPushNotificationConfig' gRPC method (v0.3)."""
273269
270+ @validate (
271+ lambda _ : self .agent_card .capabilities .push_notifications ,
272+ 'Push notifications are not supported by the agent' ,
273+ )
274274 async def _handler (
275275 server_context : ServerCallContext ,
276276 ) -> a2a_v0_3_pb2 .TaskPushNotificationConfig :
0 commit comments