a2a.client.base_client module

class a2a.client.base_client.BaseClient(card: AgentCard, config: ClientConfig, transport: ClientTransport, interceptors: list[ClientCallInterceptor])

Bases: Client

Base implementation of the A2A client, containing transport-independent logic.

async cancel_task(request: CancelTaskRequest, *, context: ClientCallContext | None = None) Task

Requests the agent to cancel a specific task.

Parameters:
  • request – The CancelTaskRequest object specifying the task ID.

  • context – Optional client call context.

Returns:

A Task object containing the updated task status.

async close() None

Closes the underlying transport.

async create_task_push_notification_config(request: TaskPushNotificationConfig, *, context: ClientCallContext | None = None) TaskPushNotificationConfig

Sets or updates the push notification configuration for a specific task.

Parameters:
  • request – The TaskPushNotificationConfig object with the new configuration.

  • context – Optional client call context.

Returns:

The created or updated TaskPushNotificationConfig object.

async delete_task_push_notification_config(request: DeleteTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None) None

Deletes the push notification configuration for a specific task.

Parameters:
  • request – The DeleteTaskPushNotificationConfigRequest object specifying the request.

  • context – Optional client call context.

async get_extended_agent_card(request: GetExtendedAgentCardRequest, *, context: ClientCallContext | None = None, signature_verifier: Callable[[AgentCard], None] | None = None) AgentCard

Retrieves the agent’s card.

This will fetch the authenticated card if necessary and update the client’s internal state with the new card.

Parameters:
  • request – The GetExtendedAgentCardRequest object specifying the request.

  • context – Optional client call context.

  • signature_verifier – A callable used to verify the agent card’s signatures.

Returns:

The AgentCard for the agent.

async get_task(request: GetTaskRequest, *, context: ClientCallContext | None = None) Task

Retrieves the current state and history of a specific task.

Parameters:
  • request – The GetTaskRequest object specifying the task ID.

  • context – Optional client call context.

Returns:

A Task object representing the current state of the task.

async get_task_push_notification_config(request: GetTaskPushNotificationConfigRequest, *, context: ClientCallContext | None = None) TaskPushNotificationConfig

Retrieves the push notification configuration for a specific task.

Parameters:
  • request – The GetTaskPushNotificationConfigParams object specifying the task.

  • context – Optional client call context.

Returns:

A TaskPushNotificationConfig object containing the configuration.

async list_task_push_notification_configs(request: ListTaskPushNotificationConfigsRequest, *, context: ClientCallContext | None = None) ListTaskPushNotificationConfigsResponse

Lists push notification configurations for a specific task.

Parameters:
  • request – The ListTaskPushNotificationConfigsRequest object specifying the request.

  • context – Optional client call context.

Returns:

A ListTaskPushNotificationConfigsResponse object.

async list_tasks(request: ListTasksRequest, *, context: ClientCallContext | None = None) ListTasksResponse

Retrieves tasks for an agent.

async send_message(request: SendMessageRequest, *, context: ClientCallContext | None = None) AsyncIterator[StreamResponse]

Sends a message to the agent.

This method handles both streaming and non-streaming (polling) interactions based on the client configuration and agent capabilities. It will yield events as they are received from the agent.

Parameters:
  • request – The message to send to the agent.

  • context – Optional client call context.

Yields:

An async iterator of StreamResponse

async subscribe(request: SubscribeToTaskRequest, *, context: ClientCallContext | None = None) AsyncIterator[StreamResponse]

Resubscribes to a task’s event stream.

This is only available if both the client and server support streaming.

Parameters:
  • request – Parameters to identify the task to resubscribe to.

  • context – Optional client call context.

Yields:

An async iterator of StreamResponse objects.

Raises:

NotImplementedError – If streaming is not supported by the client or server.