返回首页
🤖 AI / LLM
A2A 协议实战:多 Agent 协作新范式完整指南 2026
A2A(Agent-to-Agent)是 2026 年多 Agent 协作标准协议。本文从 0 到多 Agent 系统实战,含 4 个真实项目 + 与 MCP 区别 + 与 LangGraph/AutoGen 对比。
A2A · Agent-to-Agent · Multi-Agent · AI Agent · 协议 · 协作
��
今日技术简讯
📰 技术简讯 · 2026-08-09
今日聚合 6 条热门技术内容(中文素材优先)。
🤖 AI / LLM
1. Google 推出 A2A 协议 GA
- 链接:https://a2a-protocol.org/blog/ga
- 来源:Google
- 摘要:Google A2A 协议 GA,Agent-to-Agent 通信标准,多 Agent 协作。
2. Anthropic 推出 A2A 兼容
- 链接:https://www.anthropic.com/a2a-support
- 来源:Anthropic
- 摘要:Anthropic Claude 推出 A2A 完整兼容,跨厂商 Agent 互通。
3. Microsoft 推出 A2A for Copilot
- 链接:https://learn.microsoft.com/a2a-copilot
- 来源:Microsoft
- 摘要:Microsoft Copilot 推出 A2A,企业 Agent 跨平台协作。
🎨 前端 / Web
4. Vercel 推出 A2A Hosting
- 链接:https://vercel.com/blog/a2a-hosting
- 来源:Vercel
- 摘要:Vercel 推出 A2A Hosting,一键部署多 Agent 服务。
⚙️ 后端 / 架构
5. Cloudflare 推出 Agent Network
- 链接:https://blog.cloudflare.com/agent-network
- 来源:Cloudflare
- 摘要:Cloudflare 推出 Agent Network,全球 Agent 发现 + 路由 + 调用。
🚀 独立开发 / OPC
6. 即刻"A2A 多 Agent"专题
- 链接:https://m.okjike.com/a2a-multi-agent
- 来源:即刻
- 摘要:即刻 200+ 独立开发者分享 A2A 多 Agent 协作实战,研究 / 编程 / 客服 Agent 协同。
数据来源:掘金 / InfoQ 中文 / 即刻 / 少数派 / HN 采集日期:2026-08-09 (UTC+8)
��
今日深度文
A2A 协议实战:多 Agent 协作新范式完整指南 2026
一句话结论:A2A = 多 Agent 的 HTTP。Agent 发现 / 通信 / 任务分发统一协议。本文从 0 到多 Agent 协作系统。
背景
2026 年多 Agent 协作的痛点:
传统方式(各自实现):
- LangGraph:内存通信
- AutoGen:消息队列
- CrewAI:自定义协议
- 各厂商 Agent:封闭生态
→ 跨框架 Agent 无法互通
A2A 出现,统一标准:
A2A(Agent-to-Agent Protocol):
- Google 牵头
- Anthropic / OpenAI / Microsoft 支持
- Agent Card 自描述
- Task 标准化
为什么 A2A 是 2026 年关键:
- 跨厂商互通:Claude / GPT / Gemini Agent 协作
- 生态共享:发布 Agent 给其他系统
- 标准化:不再每个框架重写通信层
- 开源开放:协议完全开源
- 企业级:微软 + Google 双重支持
6 大核心优势
1. Agent Card(自描述)
// 每个 Agent 发布自己的 Agent Card
{
"name": "Research Agent",
"description": "深度研究 + 信息收集",
"url": "https://research-agent.example.com",
"version": "1.0",
"capabilities": {
"streaming": true,
"pushNotifications": true,
"stateTransition": true
},
"skills": [
{
"id": "web_search",
"name": "Web Search",
"description": "搜索网络信息"
},
{
"id": "data_analysis",
"name": "Data Analysis",
"description": "分析数据集"
}
],
"authentication": {
"schemes": ["apiKey", "oauth2"]
}
}
2. JSON-RPC over HTTP/SSE
// 发送任务
POST /tasks
{
"jsonrpc": "2.0",
"id": "1",
"method": "tasks/send",
"params": {
"id": "task-001",
"message": {
"role": "user",
"parts": [
{
"type": "text",
"text": "研究 2026 年 AI Agent 趋势"
}
]
}
}
}
// 接收响应(SSE 流式)
data: {"jsonrpc":"2.0","id":"1","result":{"id":"task-001","status":"working","artifacts":[...]}}
3. Task 生命周期
任务状态机:
pending → working → completed
↓
failed / canceled / input-required
4. Artifact(产物)
{
"type": "application/json",
"title": "研究报告",
"content": {
"summary": "2026 年 AI Agent 趋势...",
"sections": [...]
}
}
5. 跨厂商兼容
A2A 生态(2026):
- Google ADK
- Anthropic Claude Agent SDK
- Microsoft Copilot
- LangGraph
- AutoGen
- CrewAI
- Vercel AI SDK
6. 企业级安全
- OAuth 2.0 / API Key 认证
- RBAC 权限控制
- 审计日志
- 加密传输
A2A vs MCP
| 维度 | MCP(Agent ↔ 工具) | A2A(Agent ↔ Agent) |
|---|---|---|
| 通信双方 | Agent ↔ 工具 | Agent ↔ Agent |
| 目的 | 调用工具 | 协作完成任务 |
| 协议 | JSON-RPC 2.0 | JSON-RPC 2.0 |
| 状态 | 通常无状态 | 长任务有状态 |
| 流式 | 可选 | 支持 SSE |
| 鉴权 | 本地/远程 | OAuth/API Key |
| 适用 | 工具调用 | 多 Agent 协作 |
两者互补:
- MCP:Agent 调用单个工具
- A2A:Agent 之间分工协作
4 个实战项目
项目 1:研究 Agent(独立)
// research-agent.ts
import { A2AServer } from "@a2a/server";
const server = new A2AServer({
name: "research-agent",
version: "1.0",
skills: ["web_search", "data_analysis", "report_generation"],
});
server.onRequest("tasks/send", async (task) => {
const query = task.message.parts[0].text;
// 1. 搜索
const searchResults = await webSearch(query);
// 2. 分析
const analysis = await analyzeData(searchResults);
// 3. 生成报告
const report = await generateReport(analysis);
return {
status: "completed",
artifacts: [
{
type: "text",
title: "研究报告",
content: report,
},
],
};
});
// 启动
server.listen(3000);
// Agent Card: http://localhost:3000/.well-known/agent.json
项目 2:多 Agent 协作(编排)
// orchestrator.ts
import { A2AClient } from "@a2a/client";
class OrchestratorAgent {
private clients = new Map<string, A2AClient>();
async registerAgent(url: string) {
// 1. 获取 Agent Card
const card = await fetch(`${url}/.well-known/agent.json`).then(r => r.json());
// 2. 创建客户端
const client = new A2AClient({ url });
this.clients.set(card.name, client);
console.log(`✅ Registered: ${card.name} (${card.skills.length} skills)`);
}
async executeTask(task: string) {
// 1. 任务拆解
const subtasks = await this.decomposeTask(task);
// 2. 分发给 Agent
const results = await Promise.all(
subtasks.map(async (subtask) => {
const agent = this.selectAgent(subtask);
return await agent.send(subtask);
})
);
// 3. 合并结果
return this.mergeResults(results);
}
private selectAgent(subtask: SubTask): A2AClient {
// 根据 skills 匹配最合适的 Agent
for (const [name, client] of this.clients) {
if (this.hasMatchingSkill(client.card, subtask)) {
return client;
}
}
throw new Error(`No agent for: ${subtask.type}`);
}
}
// 使用
const orchestrator = new OrchestratorAgent();
await orchestrator.registerAgent("https://research-agent.com");
await orchestrator.registerAgent("https://code-agent.com");
await orchestrator.registerAgent("https://writer-agent.com");
// 任务:"写一篇关于 AI Agent 趋势的 3000 字文章"
const result = await orchestrator.executeTask("AI Agent trends 2026");
console.log(result);
项目 3:Claude Agent via A2A
// claude-a2a-server.ts
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import Anthropic from "@anthropic-ai/sdk";
const anthropic = new Anthropic();
const server = new Server(
{ name: "claude-a2a-agent", version: "1.0" },
{ capabilities: { tools: {} } }
);
// Agent Card
const agentCard = {
name: "Claude Research Agent",
description: "Powered by Claude 4.5 Sonnet",
skills: [
{ id: "research", name: "Research", description: "深度研究" },
{ id: "writing", name: "Writing", description: "技术写作" },
{ id: "analysis", name: "Analysis", description: "数据分析" },
],
};
server.setRequestHandler("tasks/send", async (task) => {
const query = task.message.parts[0].text;
// 调用 Claude
const response = await anthropic.messages.create({
model: "claude-sonnet-4-5",
max_tokens: 4096,
messages: [{ role: "user", content: query }],
});
return {
status: "completed",
artifacts: [
{
type: "text",
title: "Response",
content: response.content[0].text,
},
],
};
});
项目 4:研究 + 写作 Agent 协作
任务:"2026 年最佳 AI 编程工具"
1. Research Agent(搜索)
- "best AI coding tools 2026"
- "Claude vs Cursor vs Copilot"
- 输出:10 个工具对比
2. Code Agent(验证)
- 测试每个工具
- 输出:实测数据
3. Writer Agent(写作)
- 输入:1+2 的结果
- 输出:3000 字深度文章
4. Editor Agent(编辑)
- 输入:Writer 输出
- 输出:SEO + 风格优化
最终:1 篇高质量文章
与现有框架对比
| 维度 | LangGraph | AutoGen | A2A |
|---|---|---|---|
| 范围 | 单应用 | 单应用 | 跨应用 |
| 通信 | 内存 | 消息队列 | HTTP/SSE |
| 跨厂商 | ❌ | ❌ | ✅ |
| 状态 | 可持久化 | 可持久化 | 服务端 |
| 适用 | 复杂工作流 | 对话式多 Agent | 分布式 Agent |
5 个常见坑
坑 1:超时
// ❌ 默认超时太长
await client.send(task);
// ✅ 显式超时
await client.send(task, { timeout: 60000 });
坑 2:任务丢失
// ❌ 任务 ID 重复
const taskId = Math.random(); // 可能重复
// ✅ UUID
const taskId = crypto.randomUUID();
坑 3:状态不一致
❌ 客户端缓存任务状态
✅ 每次查询最新状态
坑 4:成本失控
❌ Agent 无限制调用
✅ 限流 + 配额 + 监控
坑 5:循环依赖
❌ Agent A 调 B,B 调 A
✅ DAG(有向无环图)
与之前内容的关系
7/11 LangGraph → 单应用多 Agent
7/12 AutoGen → 对话式多 Agent
7/13 CrewAI → 角色多 Agent
7/14 一人公司 AI Agent
8/8 MCP → 工具标准
8/9 A2A → Agent 协作标准 ← 今天
→ "工具 → Agent → 多 Agent"完整生态
7 天落地路径
Day 1:理解 A2A 概念
阅读 https://a2a-protocol.org
Day 2:构建 Research Agent
// 单 Agent + A2A Server
Day 3:注册 + 发现
# Agent Card
# /.well-known/agent.json
Day 4:多 Agent 编排
// Orchestrator
Day 5:跨厂商
// Claude + GPT + Gemini Agent 协作
Day 6:流式 + 推送
// SSE / WebSocket
Day 7:生产部署
# Vercel / Cloudflare 边缘部署
我的看法
A2A 是 2026 年多 Agent 的"HTTP 时刻":
- 跨厂商:Claude / GPT / Gemini Agent 互通
- 标准化:不再每个框架重写通信
- 生态化:可发布 Agent 给其他系统
- 开源开放:完全开源
- 企业级:Google + Microsoft 支持
对独立开发者的建议:
- 学习 A2A:多 Agent 的未来
- 构建垂直 Agent:研究 / 编程 / 设计
- 发布 Agent Card:被其他系统调用
- 加入编排:成为 Orchestrator
- 关注 MCP:配合使用(工具 + 协作)
参考
本文基于 A2A GA + Google / Anthropic / Microsoft 完整支持,2026 年 8 月最新实战。
�� 同主题文章
🤖AI / LLM·
Claude 5 + MCP 生态 2026:完整实战与生态全景
Claude 5 正式发布 + MCP 2.0 协议。Opus / Sonnet / Haiku 三档 + 百万上下文 + Claude Code SDK + MCP Server 市场。
Claude 5MCPAnthropic
🤖AI / LLM·
Pydantic AI 1.0 + 结构化输出 2026:类型安全 LLM 应用完整实战
结构化输出是 2026 LLM 应用标配。Pydantic AI / Instructor / Zod / Outlines / DSPy 5 大工具对比 + 实战 + 选型。
PydanticInstructorZod
🤖AI / LLM·
LangGraph + AI Agent 工程化 2026:4 大 Agent 框架实战指南
2026 年 AI Agent 工程化元年。LangGraph / CrewAI / AutoGen / Letta 4 大框架对比 + 6 个实战 + Agent 选型决策树。
LangGraphCrewAIAutoGen