A2AController class provides a FastAPI-compatible router that implements the A2A (Agent-to-Agent) protocol v0.3.0. It automatically exposes an agent card manifest and handles JSON-RPC based messaging.
Class Signature
Parameters
The name of the agent.
A description of the agent’s purpose and capabilities.
The base URL where the agent is hosted.
The version of the agent.
A list of skills that the agent can perform.
The capabilities supported by the agent (streaming, statefulness, async processing).
Additional keyword arguments passed to the FastAPI
APIRouter.Methods
add_handler
Register a handler function for a specific A2A protocol method.The A2A protocol method to handle. Must be one of:
message/send- Non-streaming message handlingmessage/stream- Streaming message handling with Server-Sent Eventstasks/get- Retrieve task statustasks/cancel- Cancel a running task
An async function that processes the request and returns the appropriate response type.
get_handler
Retrieve the registered handler for a specific method.run
Main JSON-RPC endpoint that routes requests to the appropriate handler.Endpoints
The controller automatically exposes these endpoints:GET /.well-known/agent-card.json- Returns the agent card manifest following A2A protocol v0.3.0POST /- Main JSON-RPC endpoint for A2A protocol operations
Usage Example
Agent Card
The agent card is automatically generated and exposed at/.well-known/agent-card.json. It includes:
- Agent metadata (name, description, version, URL)
- Supported skills
- Capabilities (streaming, statefulness, async processing)
- Security schemes and authentication requirements
- Supported input/output modes
/home/daytona/workspace/source/src/agentor/a2a.py:20