Contract for the A2A request handler — the module that actually fulfils JSON-RPC method calls once the transport has decoded + authenticated.
The handler is transport-agnostic: both A2aEngine.Transport.Http and
A2aEngine.Transport.BeamNative dispatch to the same handler contract.
Hosts implement this behaviour in their own module (e.g.
MyApp.A2A.Broker) and pass it to transports via opts.
Callbacks
handle_request/3— for unary methods (message/send,tasks/get,tasks/cancel,tasks/pushNotificationConfig/*,agent/getAuthenticatedExtendedCard). Returns{:ok, result}on success or{:error, error_map}on failure.handle_stream/4— for streaming methods (message/stream,tasks/resubscribe). Receives anemitcallback that pushes events back to the caller. Returns{:ok, final_result}when the stream completes cleanly, or{:error, error_map}on failure.
Method dispatch
Transports call dispatch/4 (this module) which pattern-matches known
A2A streaming methods to handle_stream/4 and everything else to
handle_request/3. Hosts don't need to write that wiring themselves.
Summary
Functions
Dispatch a decoded JSON-RPC request to the right handler callback.
Whether a method is an A2A streaming method (message/stream or tasks/resubscribe).
Types
Callbacks
Functions
@spec dispatch(module(), map(), context(), emit_fn() | nil) :: {:ok, term()} | {:error, error_map()} | {:streaming, term()}
Dispatch a decoded JSON-RPC request to the right handler callback.
Streaming methods go to handle_stream/4 with the provided emit_fn;
all other methods go to handle_request/3.
Whether a method is an A2A streaming method (message/stream or tasks/resubscribe).