a2a.plugins.base module

Plugin interfaces.

A plugin inherits from the interfaces it needs and overrides only the hooks it uses; every base method is a no-op.

Interceptor hooks (before_*) may modify their argument or reject the call by raising. Exceptions from after_* and observer hooks (on_*) are logged and swallowed by the plugin manager.

class a2a.plugins.base.ClientPlugin

Bases: Plugin

Hooks around each request made by an A2A Client.

async after_client_request(response: ClientResponse) → None

Called with the result, per stream event, and at the end.

async before_client_request(request: ClientRequest) → None

Called before the request is sent. Raise to cancel it.

class a2a.plugins.base.CompletePlugin

Bases: ClientPlugin, ServerPlugin

A plugin with both client and server hooks.

class a2a.plugins.base.ExecutionPlugin

Bases: Plugin

Hooks around AgentExecutor.execute, which runs outside the request.

async after_execution(request_context: RequestContext, error: BaseException | None) → None

Called in the execution task after the agent returns or raises.

async before_execution(request_context: RequestContext) → None

Called in the execution task before the agent runs.

Raise to fail the execution without running the agent.

async on_execution_event(request_context: RequestContext, event: Event) → None

Called when the agent enqueues an event, before it is processed.

Observer: runs on the agent’s path, so keep it cheap.

class a2a.plugins.base.Plugin

Bases: object

Common base of all plugins.

name: str = 'unnamed'

Name used in logs.

class a2a.plugins.base.PushPlugin

Bases: Plugin

Hooks around each push notification delivery.

async before_push_send(request: PushRequest) → None

Called before the webhook request.

May add headers or set request.skip. Raising fails the delivery.

async on_push_sent(result: PushResult) → None

Called after the delivery attempt, or when it was skipped.

class a2a.plugins.base.ServerPlugin

Bases: Plugin

Hooks around each request handled by DefaultRequestHandlerV2.

async after_handler_run(response: ServerResponse) → None

Called with the handler result, per stream event, and at the end.

async before_handler_run(request: ServerRequest) → None

Called before the handler processes a request.

Raise to reject the request; the exception is returned to the caller.

class a2a.plugins.base.TaskObserverPlugin

Bases: Plugin

Observer of task writes.

async on_task_event(info: TaskEventInfo) → None

Called after every successful task write.