3333 GetTaskResponse ,
3434 JSONRPCErrorResponse ,
3535 Message ,
36+ MessageSendConfiguration ,
3637 MessageSendParams ,
3738 SendMessageRequest ,
3839 SendMessageResponse ,
@@ -573,6 +574,14 @@ def __init__(
573574 def get_http_args (
574575 self , context : ClientCallContext
575576 ) -> dict [str , Any ] | None :
577+ """Extract HTTP-specific keyword arguments from the client call context.
578+
579+ Args:
580+ context: The client call context.
581+
582+ Returns:
583+ A dictionary of HTTP arguments, or None.
584+ """
576585 return context .state .get ('http_kwargs' , None ) if context else None
577586
578587 async def send_message (
@@ -581,6 +590,21 @@ async def send_message(
581590 * ,
582591 context : ClientCallContext | None = None ,
583592 ) -> AsyncIterator [Task | Message ]:
593+ """Send a message to the agent and consumes the response(s).
594+
595+ This method handles both blocking (non-streaming) and streaming responses
596+ based on the client configuration and agent capabilities.
597+
598+ Args:
599+ request: The message to send.
600+ context: The client call context.
601+
602+ Yields:
603+ The final message or task result from the agent.
604+
605+ Raises:
606+ JSONRPCError: If the agent returns a JSON-RPC error in the response.
607+ """
584608 config = MessageSendConfiguration (
585609 accepted_output_modes = self ._config .accepted_output_modes ,
586610 blocking = not self ._config .polling ,
@@ -642,6 +666,15 @@ async def get_task(
642666 * ,
643667 context : ClientCallContext | None = None ,
644668 ) -> Task :
669+ """Retrieve a task from the agent.
670+
671+ Args:
672+ request: Parameters to identify the task.
673+ context: The client call context.
674+
675+ Returns:
676+ The requested task.
677+ """
645678 response = await self ._transport_client .get_task (
646679 GetTaskRequest (
647680 params = request ,
@@ -658,6 +691,15 @@ async def cancel_task(
658691 * ,
659692 context : ClientCallContext | None = None ,
660693 ) -> Task :
694+ """Cancel an ongoing task on the agent.
695+
696+ Args:
697+ request: Parameters to identify the task to cancel.
698+ context: The client call context.
699+
700+ Returns:
701+ The task after the cancellation request.
702+ """
661703 response = await self ._transport_client .cancel_task (
662704 CancelTaskRequest (
663705 params = request ,
@@ -674,6 +716,15 @@ async def set_task_callback(
674716 * ,
675717 context : ClientCallContext | None = None ,
676718 ) -> TaskPushNotificationConfig :
719+ """Set a push notification callback for a task.
720+
721+ Args:
722+ request: The push notification configuration to set.
723+ context: The client call context.
724+
725+ Returns:
726+ The configured task push notification configuration.
727+ """
677728 response = await self ._transport_client .set_task_callback (
678729 SetTaskPushNotificationConfigRequest (
679730 params = request ,
@@ -690,6 +741,15 @@ async def get_task_callback(
690741 * ,
691742 context : ClientCallContext | None = None ,
692743 ) -> TaskPushNotificationConfig :
744+ """Retrieve the push notification callback configuration for a task.
745+
746+ Args:
747+ request: Parameters to identify the task and configuration.
748+ context: The client call context.
749+
750+ Returns:
751+ The requested task push notification configuration.
752+ """
693753 response = await self ._transport_client .get_task_callback (
694754 GetTaskPushNotificationConfigRequest (
695755 params = request ,
@@ -706,6 +766,20 @@ async def resubscribe(
706766 * ,
707767 context : ClientCallContext | None = None ,
708768 ) -> AsyncIterator [Task | Message ]:
769+ """Resubscribe to a task's event stream.
770+
771+ This is only available if both the client and server support streaming.
772+
773+ Args:
774+ request: Parameters to identify the task to resubscribe to.
775+ context: The client call context.
776+
777+ Yields:
778+ Task events from the agent.
779+
780+ Raises:
781+ Exception: If streaming is not supported.
782+ """
709783 if not self ._config .streaming or not self ._card .capabilities .streaming :
710784 raise Exception (
711785 'client and/or server do not support resubscription.'
@@ -726,17 +800,28 @@ async def get_card(
726800 * ,
727801 context : ClientCallContext | None = None ,
728802 ) -> AgentCard :
803+ """Retrieve the agent's card.
804+
805+ This may involve fetching the public card first if not already available,
806+ and then fetching the authenticated extended card if supported and required.
807+
808+ Args:
809+ context: The client call context.
810+
811+ Returns:
812+ The agent's card.
813+ """
729814 return await self ._transport_client .get_card (
730815 http_kwargs = self .get_http_args (context ),
731816 context = context ,
732817 )
733818
734819
735- def NewJsonRpcClient (
820+ def NewJsonRpcClient ( # noqa: N802
736821 card : AgentCard ,
737822 config : ClientConfig ,
738823 consumers : list [Consumer ],
739824 middleware : list [ClientCallInterceptor ],
740825) -> Client :
741- """Generator for the `JsonRpcClient` implementation."""
826+ """Factory function for the `JsonRpcClient` implementation."""
742827 return JsonRpcClient (card , config , consumers , middleware )
0 commit comments