Skip to main content

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 with agent.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):
The agent card is now available at:

Agent Card

The agent card describes agent capabilities, endpoints, and skills (src/agentor/a2a.py:53):

Agent Capabilities

The capabilities 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

The A2AController (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):
The response is an event stream with:
  1. Task - Initial task object
  2. TaskArtifactUpdateEvent - Streaming content updates
  3. 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):
Implement your own handler:

Agent Skills in A2A

Tools are automatically exposed as agent skills (src/agentor/core/agent.py:535):

Complete Server Example

From examples/agent-server/main.py:
Test the agent card:
Send a message:

Integration with FastAPI

The A2A controller is a FastAPI router (src/agentor/core/agent.py:559):
This enables:
  • Automatic OpenAPI documentation
  • Dependency injection
  • Middleware support
  • Request validation

Protocol Versioning

The current implementation uses A2A protocol v0.3.0. The agent card includes:
Future versions may add cryptographic signatures for agent verification.

Next Steps

Agents

Learn about agent architecture

Deployment

Deploy A2A-compatible agents

MCP Protocol

Compare with Model Context Protocol
Last modified on May 5, 2026