# Multi Agent Collaboration

当需要其他 agent 的专长、上下文或协作支持，或用户明确要求调用其他 agent 时，使用本 skill。先查询可用 agents，再用 qwenpaw agents...

- Repository: https://github.com/agentscope-ai/QwenPaw (37135 stars)
- Category: AI and agents
- License: Apache-2.0
- Last updated: 2026-10-30
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add agentscope-ai/QwenPaw --skill multi_agent_collaboration -g -a claude-code -y`
Codex: `npx skills add agentscope-ai/QwenPaw --skill multi_agent_collaboration -g -a codex -y`
Cursor: `npx skills add agentscope-ai/QwenPaw --skill multi_agent_collaboration -g -a cursor -y`
Gemini CLI: `npx skills add agentscope-ai/QwenPaw --skill multi_agent_collaboration -g -a gemini-cli -y`

## Description

当需要其他 agent 的专长、上下文或协作支持，或用户明确要求调用其他 agent 时，使用本 skill。先查询可用 agents，再用 qwenpaw agents chat 进行双向沟通。

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# 多智能体协作

## 什么时候用

当你**需要其他 agent 的专业能力、上下文、workspace 内容或协作支持**时，使用本 skill。  
如果**用户明确要求某个 agent 参与/协助/回答**，也应使用本 skill。

### 应该使用
- 当前任务明显更适合某个专用 agent
- 需要另一个 agent 的 workspace / 文件 / 上下文
- 需要第二意见或专业复核
- 用户明确要求某个 agent 参与或调用其他 agent

### 不应使用
- 你自己可以直接完成，且用户没有明确要求调用其他 agent
- 只是普通问答，不需要专门 agent
- 信息不足，应先追问用户
- 刚收到 Agent B 的消息，**不要再调用 Agent B**，避免循环

## 决策规则

1. **如果用户明确要求调用其他 agent，优先按要求执行**
2. **否则，能自己做，就不要调用**
3. **调用前先查 agent，不要猜 ID**
4. **需要上下文续聊时，必须传 `--session-id`**
5. **不要回调消息来源 agent**

---

## 最常用命令

### 1) 先查询可用 agents

```bash
qwenpaw agents list
```

### 2) 发起新对话（实时模式）

```bash
qwenpaw agents chat \
  --from-agent <your_agent> \
  --to-agent <target_agent> \
  --text "[Agent <your_agent> requesting] ..."
```

### 3) 发起复杂任务（后台模式）

**复杂任务**包括：数据分析、报告生成、批量处理、外部API调用等。

```bash
qwenpaw agents chat --background \
  --from-agent <your_agent> \
  --to-agent <target_agent> \
  --text "[Agent <your_agent> requesting] ..."
```

**输出**：
```
[TASK_ID: xxx-xxx-xxx]
[SESSION: ...]
```

### 4) 查询后台任务状态

```bash
qwenpaw agents chat --background --task-id <task_id>
```

**重要**：不要频繁查询！提交任务后：
1. **不要硬等** - 继续处理其他任务或工作
2. **等待合理时间后再查** - 根据任务复杂度选择：
   - 简单分析：10-20 秒后查询
   - 复杂分析：30-60 秒后查询
   - 批量处理：1-3 分钟后查询
3. **在等待期间** - 可以回复用户、处理其他请求、或执行其他任务

### 5) 继续已有对话

```bash
qwenpaw agents chat \
  --from-agent <your_agent> \
  --to-agent <target_agent> \
  --session-id "<session_id>" \
  --text "[Agent <your_agent> requesting] ..."
```

**重点**:
- 不传 `--session-id` = 新对话
- 传 `--session-id` = 续聊（保留上下文）
- 复杂任务用 `--background`，提交后记录 task_id

---

## 任务模式选择

### 实时模式 vs 后台模式

| 任务类型 | 使用模式 | 命令 |
|---------|---------|------|
| 简单快速查询 | 实时模式 | `qwenpaw agents chat` |
| 复杂任务（数据分析、批量处理等） | 后台模式 | `qwenpaw agents chat --background` |

**复杂任务示例**：
- 分析大量数据或日志文件
- 生成详细报告
- 批量处理文件（10+ 个文件）
- 调用慢速外部 API
- 需要并行执行的独立任务

**判断标准**：如果不确定任务会花多长时间，或者任务很复杂，优先使用后台模式。

---

## 最小工作流

### 实时模式工作流

The rest: https://github.com/agentscope-ai/QwenPaw/blob/HEAD/src/qwenpaw/agents/skills/multi_agent_collaboration-zh/SKILL.md
