一个 Agent 有用。一组 Agent 是竞争优势。
这是多 Agent orchestration 的核心前提,也是一份完整指南的开篇。
单一 Agent 的瓶颈
单个 Agent 可以研究、写文章、分析或编码,但不能同时把这一切都做好。就像一个员工试图同时做研究、写稿、销售和客服,结果每件事都做得很差。
解决方案和人类几百年前发现的解法一样:专业化分工。
Hub and Spoke 架构
所有有效的多 Agent 系统都遵循同一套基础模式:
[Coordinator / Hub]
/ | | \
[Research] [Analysis] [Writing]
Specialist Specialist Specialist
Hub(Coordinator Agent):
- 接收用户整体目标
- 分解为子任务
- 决定哪个 specialist 处理哪个子任务
- 在 specialist 之间传递 context
- 组装最终输出
Spokes(Specialist Agents):
- 每个是专注的专家
- 有明确的角色定义、小而精的工具集
- 约束在自己的专业范围内
所有通信都经过 coordinator,specialist 之间不直接对话。coordinator 是 routing、质量控制和组装的单一入口。
最常见的 Bug
Specialist agents do NOT automatically inherit the coordinator's conversation history.
当 coordinator spawn 一个 specialist,specialist 从零开始——它不知道任何事,没有读过对话历史,没有看到其他 specialist 的产出。如果 coordinator 只是说"根据我们的研究写一份报告",writing specialist 完全不知道做了哪些研究。
所有 context 必须显式传递。这不是可选的,是唯一有效的方式。
# 错误——specialist 没有 context
writer_prompt = "Write a market analysis report based on the research."
# 正确——所有 context 显式传入
writer_prompt = f"""You are a professional report writer.
Write a market analysis report using the research findings below.
RESEARCH FINDINGS:
{research_data}
KEY STATISTICS:
{statistics}
COMPETITOR ANALYSIS:
{competitor_data}
FORMAT: Executive summary (3 sentences), then 5 sections with headers,
each 2-3 paragraphs. Professional tone. Cite specific numbers.
AUDIENCE: C-level executives who will read this in under 10 minutes.
"""
完整团队示例
Research Specialist → Analyst Specialist → Writer Specialist
- Research:搜索信息,提取关键事实,编译原始研究数据
- Analyst:从原始数据中识别模式,得出结论,发现来源之间的矛盾
- Writer:将分析后的数据转化为格式和语调明确的 polished 报告
Coordinator 在每个阶段显式传递 context:研究数据给 Analyst,分析结果给 Writer。每一步都是完整的一手上下文,而不是模糊的指令。