Import cost: importing just the server side of A2A does not pull in the HTTP client stack.
A2AClient is lazy-loaded via the package’s __getattr__ — the first time you reference it, aiohttp is imported. Server-only deployments that never touch A2AClient never pay that cost. aiohttp remains a core dependency; this is an import-time optimisation, not a dependency change.Quick Start
1
Simple Agent Server
2
FastAPI Integration
JSON-RPC Methods
The A2A server exposes six JSON-RPC 2.0 methods for complete task lifecycle management:message/send
Send a message and receive the complete task result:message/stream
Send a message and receive real-time updates via Server-Sent Events:message/stream behaves like message/send: the task moves through working → completed | failed | cancelled in the task store, concurrent streams don’t block each other, AgentTeam is supported, and tasks/cancel reaches a running stream. After the stream ends, tasks/get for the same task ID returns the finished task with its history and artifact.
If the agent raises an error, the final failed event carries the reason in status.message:
tasks/cancel lands while the stream is running, the stream ends with a final cancelled event:
If the client disconnects before the stream finishes, the task is marked
cancelled.tasks/get
Retrieve an existing task by ID:tasks/cancel
Cancel a running task:completed, failed, or cancelled, the state is left unchanged and an error is returned:
A cancelled task is final — any background completion that arrives later is discarded, not applied.
Configuration Options
Multi-Agent Support
Route messages to multi-agent workflows usingAgentTeam:
message/send and message/stream work with AgentTeam — a team endpoint streams the team’s final result just like a single agent.
When both
agent and agents are provided, the single agent takes priority.Streaming Events
Event Types
Agent Card
The Agent Card is automatically generated from your agent’s configuration:GET /.well-known/agent.json
Message Parts
A2A messages support multimodal content through different part types:A2UI payloads
When an agent usessend_a2ui_messages, sync message/send artifacts may include a DataPart with metadata.mimeType of application/json+a2ui. Use create_a2ui_part() / is_a2ui_part() from praisonaiagents.ui.a2ui for manual wrapping.
A2A
message/stream currently emits text-only artifacts. For live A2UI during streaming, prefer AG-UI or PraisonAIUI.Authentication
Protect your A2A endpoint with bearer token authentication:Task Lifecycle
Streamed tasks (message/stream) follow the same lifecycle as message/send tasks.
Docker Deployment
Best Practices
Protect production endpoints
Protect production endpoints
Set
auth_token on any A2A server exposed beyond localhost. The discovery card stays public per spec — keep sensitive skills and tools out of the advertised card when auth is required.Prefer streaming for long tasks
Prefer streaming for long tasks
Use
message/stream when responses may take more than a few seconds. Clients receive progress via SSE instead of blocking on a single JSON-RPC response. Streams run concurrently, so multiple clients can stream from the same server without waiting on each other.Use AgentTeam for multi-step work
Use AgentTeam for multi-step work
Route complex workflows through
AgentTeam rather than chaining multiple single agents. One A2A endpoint can orchestrate monitor → act → feedback loops cleanly.Publish accurate agent cards
Publish accurate agent cards
Keep
name, description, and url aligned with your deployment. External agents discover capabilities via GET /.well-known/agent.json — stale URLs break inter-agent handoffs.Task store retention
Task store retention
Tasks live in memory, per server instance, and do not persist across restarts. The store holds up to ~10,000 tasks; beyond that, the oldest terminal tasks are evicted. Live tasks are never evicted.
Related
A2UI Protocol
Declarative UI via send_a2ui_messages and DataPart artifacts
A2A Client
A2A client for connecting to other agents
MCP Lifecycle
Model Context Protocol for tool integration

