@@ -144,11 +144,6 @@ def __init__( # noqa: PLR0913
144144 # asyncio tasks and to surface unexpected exceptions.
145145 self ._background_tasks = set ()
146146
147- @property
148- def agent_card (self ) -> AgentCard :
149- """The agent card to be served by default."""
150- return self ._agent_card
151-
152147 @validate_request_params
153148 async def on_get_task (
154149 self ,
@@ -424,7 +419,7 @@ async def push_notification_callback(event: Event) -> None:
424419
425420 @validate_request_params
426421 @validate (
427- lambda self : self .agent_card .capabilities .streaming ,
422+ lambda self : self ._agent_card .capabilities .streaming ,
428423 'Streaming is not supported by the agent' ,
429424 )
430425 async def on_message_send_stream (
@@ -517,10 +512,7 @@ async def _cleanup_producer(
517512
518513 @validate_request_params
519514 @validate (
520- lambda self : (
521- self .agent_card .capabilities .push_notifications
522- and self ._push_config_store
523- ),
515+ lambda self : self ._agent_card .capabilities .push_notifications ,
524516 error_message = 'Push notifications are not supported by the agent' ,
525517 error_type = PushNotificationNotSupportedError ,
526518 )
@@ -533,12 +525,15 @@ async def on_create_task_push_notification_config(
533525
534526 Requires a `PushNotifier` to be configured.
535527 """
528+ if not self ._push_config_store :
529+ raise PushNotificationNotSupportedError
530+
536531 task_id = params .task_id
537532 task : Task | None = await self .task_store .get (task_id , context )
538533 if not task :
539534 raise TaskNotFoundError
540535
541- await self ._push_config_store .set_info ( # type: ignore[union-attr]
536+ await self ._push_config_store .set_info (
542537 task_id ,
543538 params ,
544539 context ,
@@ -548,10 +543,7 @@ async def on_create_task_push_notification_config(
548543
549544 @validate_request_params
550545 @validate (
551- lambda self : (
552- self .agent_card .capabilities .push_notifications
553- and self ._push_config_store
554- ),
546+ lambda self : self ._agent_card .capabilities .push_notifications ,
555547 error_message = 'Push notifications are not supported by the agent' ,
556548 error_type = PushNotificationNotSupportedError ,
557549 )
@@ -564,14 +556,17 @@ async def on_get_task_push_notification_config(
564556
565557 Requires a `PushConfigStore` to be configured.
566558 """
559+ if not self ._push_config_store :
560+ raise PushNotificationNotSupportedError
561+
567562 task_id = params .task_id
568563 config_id = params .id
569564 task : Task | None = await self .task_store .get (task_id , context )
570565 if not task :
571566 raise TaskNotFoundError
572567
573568 push_notification_configs : list [TaskPushNotificationConfig ] = (
574- await self ._push_config_store .get_info (task_id , context ) or [] # type: ignore[union-attr]
569+ await self ._push_config_store .get_info (task_id , context ) or []
575570 )
576571
577572 for config in push_notification_configs :
@@ -582,7 +577,7 @@ async def on_get_task_push_notification_config(
582577
583578 @validate_request_params
584579 @validate (
585- lambda self : self .agent_card .capabilities .streaming ,
580+ lambda self : self ._agent_card .capabilities .streaming ,
586581 'Streaming is not supported by the agent' ,
587582 )
588583 async def on_subscribe_to_task (
@@ -629,10 +624,7 @@ async def on_subscribe_to_task(
629624
630625 @validate_request_params
631626 @validate (
632- lambda self : (
633- self .agent_card .capabilities .push_notifications
634- and self ._push_config_store
635- ),
627+ lambda self : self ._agent_card .capabilities .push_notifications ,
636628 error_message = 'Push notifications are not supported by the agent' ,
637629 error_type = PushNotificationNotSupportedError ,
638630 )
@@ -645,12 +637,15 @@ async def on_list_task_push_notification_configs(
645637
646638 Requires a `PushConfigStore` to be configured.
647639 """
640+ if not self ._push_config_store :
641+ raise PushNotificationNotSupportedError
642+
648643 task_id = params .task_id
649644 task : Task | None = await self .task_store .get (task_id , context )
650645 if not task :
651646 raise TaskNotFoundError
652647
653- push_notification_config_list = await self ._push_config_store .get_info ( # type: ignore[union-attr]
648+ push_notification_config_list = await self ._push_config_store .get_info (
654649 task_id , context
655650 )
656651
@@ -660,10 +655,7 @@ async def on_list_task_push_notification_configs(
660655
661656 @validate_request_params
662657 @validate (
663- lambda self : (
664- self .agent_card .capabilities .push_notifications
665- and self ._push_config_store
666- ),
658+ lambda self : self ._agent_card .capabilities .push_notifications ,
667659 error_message = 'Push notifications are not supported by the agent' ,
668660 error_type = PushNotificationNotSupportedError ,
669661 )
@@ -676,17 +668,24 @@ async def on_delete_task_push_notification_config(
676668
677669 Requires a `PushConfigStore` to be configured.
678670 """
671+ if not self ._push_config_store :
672+ raise PushNotificationNotSupportedError
673+
679674 task_id = params .task_id
680675 config_id = params .id
681676 task : Task | None = await self .task_store .get (task_id , context )
682677 if not task :
683678 raise TaskNotFoundError
684679
685- await self ._push_config_store .delete_info (task_id , context , config_id ) # type: ignore[union-attr]
680+ await self ._push_config_store .delete_info (task_id , context , config_id )
686681
687682 @validate_request_params
688683 @validate (
689- lambda self : self .agent_card .capabilities .extended_agent_card ,
684+ lambda self : self ._agent_card .capabilities .extended_agent_card ,
685+ error_message = 'The agent does not support authenticated extended cards' ,
686+ )
687+ @validate (
688+ lambda self : self .extended_agent_card ,
690689 error_message = 'The agent does not have an extended agent card configured' ,
691690 error_type = ExtendedAgentCardNotConfiguredError ,
692691 )
@@ -699,12 +698,11 @@ async def on_get_extended_agent_card(
699698
700699 Requires `capabilities.extended_agent_card` to be true.
701700 """
702- card = self .extended_agent_card or self . agent_card
701+ extended_card = self .extended_agent_card
703702
704703 if self .extended_card_modifier :
705- return await maybe_await (self .extended_card_modifier (card , context ))
706-
707- if self .card_modifier :
708- return await maybe_await (self .card_modifier (card ))
704+ return await maybe_await (
705+ self .extended_card_modifier (extended_card , context )
706+ )
709707
710- return card
708+ return extended_card
0 commit comments