Overview
The Agent-to-Agent (A2A) Protocol defines standard specifications for agent communication and message formatting, enabling seamless interoperability between different AI agents. Every agent served withagent.serve() automatically becomes A2A-compatible with standardized endpoints and agent card discovery.
Key Features
- Standard Communication - JSON-RPC 2.0 based messaging
- Agent Discovery - Automatic agent card generation at
/.well-known/agent-card.json - Rich Interactions - Support for tasks, status updates, and artifact streaming
- Protocol Version - Implements A2A protocol v0.3.0
Quick Start
Serving an agent automatically enables A2A protocol (src/agentor/core/agent.py:513):Agent Card
The agent card describes agent capabilities, endpoints, and skills (src/agentor/a2a.py:53):Agent Capabilities
Thecapabilities object (src/agentor/a2a.py:40) indicates:
- streaming - Supports Server-Sent Events for real-time responses
- statefulness - Maintains conversation context across requests
- asyncProcessing - Can handle long-running tasks
A2A Controller
TheA2AController (src/agentor/a2a.py:20) implements the A2A protocol on top of FastAPI:
Custom Endpoints
Add custom routes to the controller (src/agentor/core/agent.py:554):JSON-RPC Methods
A2A protocol implements these JSON-RPC 2.0 methods (src/agentor/a2a.py:90):message/send
Send a non-streaming message:message/stream
Send a streaming message with Server-Sent Events (src/agentor/a2a.py:114):- Task - Initial task object
- TaskArtifactUpdateEvent - Streaming content updates
- TaskStatusUpdateEvent - Final completion status
tasks/get
Retrieve task status:tasks/cancel
Cancel a running task:Streaming Implementation
The streaming handler (src/agentor/core/agent.py:579) sends events in Server-Sent Events format:Task States
Tasks progress through these states:- working - Task is processing
- completed - Task finished successfully
- failed - Task encountered an error
Error Handling
Errors are reported in the JSON-RPC error format (src/agentor/core/schema.py):Error Codes
Custom Handlers
Register custom A2A handlers (src/agentor/core/agent.py:576):Agent Skills in A2A
Tools are automatically exposed as agent skills (src/agentor/core/agent.py:535):Complete Server Example
Fromexamples/agent-server/main.py:
Integration with FastAPI
The A2A controller is a FastAPI router (src/agentor/core/agent.py:559):- Automatic OpenAPI documentation
- Dependency injection
- Middleware support
- Request validation
Protocol Versioning
The current implementation uses A2A protocol v0.3.0. The agent card includes:Next Steps
Agents
Learn about agent architecture
Deployment
Deploy A2A-compatible agents
MCP Protocol
Compare with Model Context Protocol