@@ -589,6 +589,14 @@ def __init__(
589
589
def get_http_args (
590
590
self , context : ClientCallContext
591
591
) -> dict [str , Any ] | None :
592
+ """Extract HTTP-specific keyword arguments from the client call context.
593
+
594
+ Args:
595
+ context: The client call context.
596
+
597
+ Returns:
598
+ A dictionary of HTTP arguments, or None.
599
+ """
592
600
return context .state .get ('http_kwargs' , None ) if context else None
593
601
594
602
async def send_message (
@@ -597,6 +605,18 @@ async def send_message(
597
605
* ,
598
606
context : ClientCallContext | None = None ,
599
607
) -> AsyncIterator [Task | Message ]:
608
+ """Send a message to the agent and consumes the response(s).
609
+
610
+ This method handles both blocking (non-streaming) and streaming responses
611
+ based on the client configuration and agent capabilities.
612
+
613
+ Args:
614
+ request: The message to send.
615
+ context: The client call context.
616
+
617
+ Yields:
618
+ The final message or task result from the agent.
619
+ """
600
620
config = MessageSendConfiguration (
601
621
accepted_output_modes = self ._config .accepted_output_modes ,
602
622
blocking = not self ._config .polling ,
@@ -648,6 +668,15 @@ async def get_task(
648
668
* ,
649
669
context : ClientCallContext | None = None ,
650
670
) -> Task :
671
+ """Retrieve a task from the agent.
672
+
673
+ Args:
674
+ request: Parameters to identify the task.
675
+ context: The client call context.
676
+
677
+ Returns:
678
+ The requested task.
679
+ """
651
680
return await self ._transport_client .get_task (
652
681
request ,
653
682
http_kwargs = self .get_http_args (context ),
@@ -660,6 +689,15 @@ async def cancel_task(
660
689
* ,
661
690
context : ClientCallContext | None = None ,
662
691
) -> Task :
692
+ """Cancel an ongoing task on the agent.
693
+
694
+ Args:
695
+ request: Parameters to identify the task to cancel.
696
+ context: The client call context.
697
+
698
+ Returns:
699
+ The task after the cancellation request.
700
+ """
663
701
return await self ._transport_client .cancel_task (
664
702
request ,
665
703
http_kwargs = self .get_http_args (context ),
@@ -672,6 +710,15 @@ async def set_task_callback(
672
710
* ,
673
711
context : ClientCallContext | None = None ,
674
712
) -> TaskPushNotificationConfig :
713
+ """Set a push notification callback for a task.
714
+
715
+ Args:
716
+ request: The push notification configuration to set.
717
+ context: The client call context.
718
+
719
+ Returns:
720
+ The configured task push notification configuration.
721
+ """
675
722
return await self ._transport_client .set_task_callback (
676
723
request ,
677
724
http_kwargs = self .get_http_args (context ),
@@ -684,6 +731,15 @@ async def get_task_callback(
684
731
* ,
685
732
context : ClientCallContext | None = None ,
686
733
) -> TaskPushNotificationConfig :
734
+ """Retrieve the push notification callback configuration for a task.
735
+
736
+ Args:
737
+ request: Parameters to identify the task and configuration.
738
+ context: The client call context.
739
+
740
+ Returns:
741
+ The requested task push notification configuration.
742
+ """
687
743
return await self ._transport_client .get_task_callback (
688
744
request ,
689
745
http_kwargs = self .get_http_args (context ),
@@ -696,6 +752,20 @@ async def resubscribe(
696
752
* ,
697
753
context : ClientCallContext | None = None ,
698
754
) -> AsyncIterator [Task | Message ]:
755
+ """Resubscribe to a task's event stream.
756
+
757
+ This is only available if both the client and server support streaming.
758
+
759
+ Args:
760
+ request: Parameters to identify the task to resubscribe to.
761
+ context: The client call context.
762
+
763
+ Yields:
764
+ Task events from the agent.
765
+
766
+ Raises:
767
+ Exception: If streaming is not supported.
768
+ """
699
769
if not self ._config .streaming or not self ._card .capabilities .streaming :
700
770
raise Exception (
701
771
'client and/or server do not support resubscription.'
@@ -713,17 +783,28 @@ async def get_card(
713
783
* ,
714
784
context : ClientCallContext | None = None ,
715
785
) -> AgentCard :
786
+ """Retrieve the agent's card.
787
+
788
+ This may involve fetching the public card first if not already available,
789
+ and then fetching the authenticated extended card if supported and required.
790
+
791
+ Args:
792
+ context: The client call context.
793
+
794
+ Returns:
795
+ The agent's card.
796
+ """
716
797
return await self ._transport_client .get_card (
717
798
http_kwargs = self .get_http_args (context ),
718
799
context = context ,
719
800
)
720
801
721
802
722
- def NewRestfulClient (
803
+ def new_restful_client (
723
804
card : AgentCard ,
724
805
config : ClientConfig ,
725
806
consumers : list [Consumer ],
726
807
middleware : list [ClientCallInterceptor ],
727
808
) -> Client :
728
- """Generator for the `RestClient` implementation."""
809
+ """Factory function for the `RestClient` implementation."""
729
810
return RestClient (card , config , consumers , middleware )
0 commit comments