What is A2A?
The A2A Protocol is a JSON-RPC based specification that defines:- Standard Communication: JSON-RPC messaging with streaming and non-streaming support
- Agent Discovery: Automatic agent cards describing capabilities and endpoints
- Rich Interactions: Tasks, status updates, and artifact sharing
- Interoperability: Works across different frameworks and platforms
Quick Start
Every agent served with Agentor automatically supports A2A:Agent Card
The agent card is a manifest that describes your agent’s capabilities:A2A Endpoints
When you serve an agent, these endpoints are automatically created:GET /.well-known/agent-card.json- Agent discoveryPOST /- JSON-RPC endpoint for all A2A operationsPOST /chat- Simplified chat endpoint
Supported Methods
message/send- Send a message and get a responsemessage/stream- Send a message and stream the responsetasks/get- Get task status (if implemented)tasks/cancel- Cancel a running task (if implemented)
Custom A2A Server
For advanced use cases, customize the A2A controller:Streaming Responses
The A2A protocol supports Server-Sent Events (SSE) for streaming:Server Side
Client Side
Send a streaming request:Task Management
A2A includes task lifecycle management:Multi-Agent Orchestration
Coordinate multiple agents:Agent Discovery
Discover available agents by fetching their agent cards:Best Practices
agent = Agentor(
name="Data Analyst Agent",
model="gpt-5-mini",
instructions="""
You are a data analyst agent specialized in:
- Statistical analysis
- Data visualization recommendations
- Trend identification
You do NOT write code or access databases directly.
"""
)
from agentor.a2a import AgentSkill
skills = [
AgentSkill(
id="analyze_data",
name="Analyze Data",
description="Perform statistical analysis on datasets",
tags=["statistics", "analysis", "data"]
),
AgentSkill(
id="visualize",
name="Recommend Visualizations",
description="Suggest appropriate charts and graphs for data",
tags=["visualization", "charts"]
)
]
async def safe_agent_call(agent, message):
"""Call an agent with error handling."""
try:
result = await agent.arun(message)
return result.final_output
except Exception as e:
print(f"Agent error: {e}")
return None
controller = A2AController(
name="My Agent",
version="2.1.0", # Semantic versioning
description="Agent with enhanced capabilities"
)
# Client polls for status
def wait_for_task(agent_url, task_id, timeout=60):
import time
start = time.time()
while time.time() - start < timeout:
response = requests.post(
agent_url,
json={
"jsonrpc": "2.0",
"id": 1,
"method": "tasks/get",
"params": {"task_id": task_id}
}
)
task = response.json()["result"]
if task["status"]["state"] in ["completed", "failed"]:
return task
time.sleep(1)
raise TimeoutError("Task did not complete in time")
Deployment
Deploy A2A-enabled agents to Celesto:Next Steps
- Enable streaming responses for real-time agent communication
- Set up observability to monitor agent interactions
- Learn about deployment best practices