Skip to main content
PraisonAI supports the A2A Protocol for agent-to-agent communication, enabling your agents to be discovered and collaborate with other AI agents via JSON-RPC 2.0.
The user publishes an agent as an A2A server; other agents discover it via the agent card and collaborate over JSON-RPC.
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:
Response:

message/stream

Send a message and receive real-time updates via Server-Sent Events:
SSE Event Format:
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:
If 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:
Success response:
If the task is already 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 using AgentTeam:
Both 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:
Access via: GET /.well-known/agent.json

Message Parts

A2A messages support multimodal content through different part types:

A2UI payloads

When an agent uses send_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.
See A2UI Protocol for the tool contract and renderer options.

Authentication

Protect your A2A endpoint with bearer token authentication:
Authenticated requests:
The discovery endpoint (/.well-known/agent.json) remains public per A2A spec. Only POST /a2a requires authentication.

Task Lifecycle

Streamed tasks (message/stream) follow the same lifecycle as message/send tasks.

Docker Deployment

requirements.txt:

Best Practices

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.
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.
Route complex workflows through AgentTeam rather than chaining multiple single agents. One A2A endpoint can orchestrate monitor → act → feedback loops cleanly.
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.
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.

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