Updated October 20, 2018
A2A 协议集成
Date: 2025 年 12 月 28 日 Version: 0.8.0
概览
OpenAgents 现在支持 Agent2Agent (A2A) 协议,能够与基于不同框架构建的 AI 代理(如 LangGraph、CrewAI、Pydantic AI 等)实现无缝互操作。
A2A 通过 HTTP 传输在 /a2a 提供服务(默认端口为 8700),同时在 /mcp 提供 MCP,在 /studio 提供 Studio。
快速开始
在网络中启用 A2A
# network.yaml
network:
transports:
- type: "http"
config:
port: 8700
serve_a2a: true # A2A at /a2a
serve_mcp: true # MCP at /mcp
serve_studio: true # Studio at /studio访问 A2A 端点
| Endpoint | Description |
|---|---|
http://localhost:8700/a2a | JSON-RPC 2.0 端点 |
http://localhost:8700/a2a/.well-known/agent.json | Agent Card 发现 |
配置选项
HTTP Transport A2A 设置
transports:
- type: "http"
config:
port: 8700
serve_a2a: true
# Agent Card configuration
a2a_agent:
name: "My Agent Network"
version: "1.0.0"
description: "OpenAgents A2A-enabled network"
provider:
organization: "My Company"
url: "https://mycompany.com"
# Optional authentication
a2a_auth:
type: "bearer"
token_env: "A2A_AUTH_TOKEN" # Read from environmentStandalone A2A Transport (Port 8900)
用于专用的 A2A 部署:
transports:
- type: "a2a"
config:
port: 8900
host: "0.0.0.0"
agent:
name: "Standalone A2A Server"A2A 协议方法
标准 A2A 方法
| Method | Description |
|---|---|
message/send | 发送消息,创建或继续任务 |
tasks/get | 按 ID 获取任务 |
tasks/list | 列出任务并支持筛选 |
tasks/cancel | 取消正在运行的任务 |
OpenAgents 扩展
| Method | Description |
|---|---|
agents/announce | 远程代理加入网络 |
agents/withdraw | 远程代理离开网络 |
agents/list | 列出所有代理(本地 + 远程) |
events/send | 通过网络发送事件 |
示例:发送消息
curl -X POST http://localhost:8700/a2a \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "message/send",
"params": {
"message": {
"role": "user",
"parts": [{"type": "text", "text": "Hello, agent!"}]
}
},
"id": "1"
}'示例:通告远程代理
curl -X POST http://localhost:8700/a2a \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "agents/announce",
"params": {
"url": "https://remote-agent.example.com",
"agent_id": "my-remote-agent"
},
"id": "1"
}'跨协议通信
A2A 与现有传输集成,实现无缝的跨协议通信:
┌─────────────────────────────────────────┐
│ OpenAgents Network │
│ │
┌──────────┼──────────────────────────────────────┐ │
│ │ Unified Agent Registry │ │
│ │ │ │
│ ┌───────┴───────┐ ┌──────────────────────┐ │ │
│ │ Local Agents │ │ Remote Agents │ │ │
│ │ (gRPC/WS) │ │ (A2A) │ │ │
│ └───────────────┘ └──────────────────────┘ │ │
└─────────────────────────────────────────────────┘ │
│ │
│ ┌───────────────────────────┐ │
│ │ HTTP Transport :8700 │ │
│ │ │ │
│ │ /a2a ─── A2A Protocol │ │
│ │ /mcp ─── MCP Protocol │ │
│ │ /studio ─ Web UI │ │
│ └───────────────────────────┘ │
└─────────────────────────────────────────┘代理技能
技能会自动从以下来源收集:
- 本地代理 - 在代理元数据中声明的技能
- 远程 A2A 代理 - 来自 Agent Card 的技能
- Mods - 已加载 Mods 所暴露的工具
访问 Agent Card 以查看所有可用技能:
curl http://localhost:8700/a2a/.well-known/agent.json相关文档
Was this helpful?