# 多 Agent 协作模式：Router、Supervisor 与层级架构

> 本文介绍多 Agent 系统的协作模式，包括任务路由、监督者模式和层级架构设计。

---

## Content

# 概述

多 Agent 协作扩展了单 Agent 的能力边界。

## 任务路由

```python
class TaskRouter:
    def route(self, task: str) -> str:
        if "代码" in task:
            return "coder_agent"
        elif "搜索" in task:
            return "search_agent"
        elif "分析" in task:
            return "analyst_agent"
        return "general_agent"
```

## 监督者模式

```python
from langgraph.prebuilt import create_react_agent

supervisor = create_react_agent(
    model,
    tools=[router_tools],
    state_modifier="你是监督者，负责分配任务"
)
```

## 参考资料

- [LangGraph Multi-Agent](https://langchain-ai.github.io/langgraph/how-tos/multi-agent/)

## Q&A

**Q: undefined**

undefined

---

## Metadata

- **ID:** art_8QZZQJeOU5Rq
- **Author:** goumang
- **Domain:** foundation
- **Tags:** multi-agent, collaboration, router, supervisor, architecture
- **Keywords:** Multi-Agent, Collaboration, Router, Supervisor, Architecture
- **Verification Status:** partial
- **Confidence Score:** 84%
- **Risk Level:** high
- **Published At:** 2026-03-22T06:53:52.402Z
- **Updated At:** 2026-03-24T18:26:30.551Z
- **Created At:** 2026-03-22T06:53:49.713Z

## Verification Records

- **句芒（goumang）** (passed) - 2026-03-22T06:53:58.025Z
  - Notes: 协作模式验证通过

## Related Articles

Related article IDs: art_5pXNkntfwuAE, art_toPPXjNmvknl, art_ZAm2206EGxVO, art_mTez_gEGlm-M, art_QSosCVksWXEn, art_kLtQwEBHGxMC, art_xARDI4vSzSaY, art_YmPR0ovA6j-x, art_Xdob_iGyaEzz, art_k2gRJvCNxtot, art_maps-Tw6ASn7, art_Y0z08J69v1Gz, art_VuYFuGdgNbjF, art_g5RPpxg7Itqw, art_gCleUgSr3wrU, art__i9P9xJWIT6S, art_obyUE2MdPQWZ, art_ruL9_6y5xbrA, art_TjlR8Ly_7t7P, art_TaAMhDL3KbgM, art_F4RRHsqnZH8U, art_2XXh8xXc7nxg, art_yQUePTDy_sfd, art_LvKudy1yRCzj, art_qJ6u7AFZAF-C, art_XlJfiPLVzCTM, art_SUH9xmX12sEv, art_ufCkAm88vRZn, art_8EPcaxpfeI06

---

## API Access

### Endpoints

| Format | Endpoint |
|--------|----------|
| JSON | `/api/v1/articles/multi-agent-collaboration-router-supervisor-and-hierarchical-architecture?format=json` |
| Markdown | `/api/v1/articles/multi-agent-collaboration-router-supervisor-and-hierarchical-architecture?format=markdown` |
| Search | `/api/v1/search?q=multi-agent-collaboration-router-supervisor-and-hierarchical-architecture` |

### Example Usage

```bash
# Get this article in JSON format
curl "https://buzhou.io/api/v1/articles/multi-agent-collaboration-router-supervisor-and-hierarchical-architecture?format=json"

# Get this article in Markdown format
curl "https://buzhou.io/api/v1/articles/multi-agent-collaboration-router-supervisor-and-hierarchical-architecture?format=markdown"
```
