4343 ExtendedAgentCardNotConfiguredError ,
4444 InternalError ,
4545 InvalidParamsError ,
46+ PushNotificationNotSupportedError ,
4647 TaskNotCancelableError ,
4748 TaskNotFoundError ,
4849 UnsupportedOperationError ,
@@ -300,6 +301,10 @@ async def on_message_send( # noqa: D102
300301
301302 # TODO: Unify with on_message_send
302303 @validate_request_params
304+ @validate (
305+ lambda self : self ._agent_card .capabilities .streaming ,
306+ 'Streaming is not supported by the agent' ,
307+ )
303308 async def on_message_send_stream ( # noqa: D102
304309 self ,
305310 params : SendMessageRequest ,
@@ -324,6 +329,11 @@ async def on_message_send_stream( # noqa: D102
324329 yield event
325330
326331 @validate_request_params
332+ @validate (
333+ lambda self : self ._agent_card .capabilities .push_notifications ,
334+ error_message = 'Push notifications are not supported by the agent' ,
335+ error_type = PushNotificationNotSupportedError ,
336+ )
327337 async def on_create_task_push_notification_config ( # noqa: D102
328338 self ,
329339 params : TaskPushNotificationConfig ,
@@ -346,6 +356,11 @@ async def on_create_task_push_notification_config( # noqa: D102
346356 return params
347357
348358 @validate_request_params
359+ @validate (
360+ lambda self : self ._agent_card .capabilities .push_notifications ,
361+ error_message = 'Push notifications are not supported by the agent' ,
362+ error_type = PushNotificationNotSupportedError ,
363+ )
349364 async def on_get_task_push_notification_config ( # noqa: D102
350365 self ,
351366 params : GetTaskPushNotificationConfigRequest ,
@@ -371,6 +386,10 @@ async def on_get_task_push_notification_config( # noqa: D102
371386 raise InternalError (message = 'Push notification config not found' )
372387
373388 @validate_request_params
389+ @validate (
390+ lambda self : self ._agent_card .capabilities .streaming ,
391+ 'Streaming is not supported by the agent' ,
392+ )
374393 async def on_subscribe_to_task ( # noqa: D102
375394 self ,
376395 params : SubscribeToTaskRequest ,
@@ -388,6 +407,11 @@ async def on_subscribe_to_task( # noqa: D102
388407 yield event
389408
390409 @validate_request_params
410+ @validate (
411+ lambda self : self ._agent_card .capabilities .push_notifications ,
412+ error_message = 'Push notifications are not supported by the agent' ,
413+ error_type = PushNotificationNotSupportedError ,
414+ )
391415 async def on_list_task_push_notification_configs ( # noqa: D102
392416 self ,
393417 params : ListTaskPushNotificationConfigsRequest ,
@@ -410,6 +434,11 @@ async def on_list_task_push_notification_configs( # noqa: D102
410434 )
411435
412436 @validate_request_params
437+ @validate (
438+ lambda self : self ._agent_card .capabilities .push_notifications ,
439+ error_message = 'Push notifications are not supported by the agent' ,
440+ error_type = PushNotificationNotSupportedError ,
441+ )
413442 async def on_delete_task_push_notification_config ( # noqa: D102
414443 self ,
415444 params : DeleteTaskPushNotificationConfigRequest ,
0 commit comments