Launch multiple sub-agents to work in parallel via Agent Tool, track tasks with WeCom smart sheets, and notify results via messages.
Initial Configuration (Automatic Initialization)
Before performing any operation, first check whether a multi-agent collaboration configuration already exists in memory. If not, automatically create it according to the following process:
Step 1: Create a smart sheet
wecom-cli doc create_doc '{"doc_type": 10, "doc_name": "多代理开发任务"}'
Obtain from the returned result docid。
Step 2: Create sub-sheets and fields
# 创建子表1: 开发任务
wecom-cli doc smartsheet_add_sheet '{"docid": "<DOCID>", "sheet_name": "开发任务"}'
# 创建子表2: 竞赛记录
wecom-cli doc smartsheet_add_sheet '{"docid": "<DOCID>", "sheet_name": "竞赛记录"}'
Development task fields:
wecom-cli doc smartsheet_add_fields '{"docid": "<DOCID>", "sheet_id": "<SHEET_ID>", "fields": [
{"field_title": "任务描述", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "工作模式", "field_type": "FIELD_TYPE_SINGLE_SELECT"},
{"field_title": "分配代理", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "状态", "field_type": "FIELD_TYPE_SINGLE_SELECT"},
{"field_title": "结果摘要", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "耗时", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "创建时间", "field_type": "FIELD_TYPE_TEXT"}
]}'
Competition record fields:
wecom-cli doc smartsheet_add_fields '{"docid": "<DOCID>", "sheet_id": "<SHEET_ID>", "fields": [
{"field_title": "任务描述", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "代理1方案", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "代理1评分", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "代理2方案", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "代理2评分", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "推荐方案", "field_type": "FIELD_TYPE_SINGLE_SELECT"},
{"field_title": "对比分析", "field_type": "FIELD_TYPE_TEXT"},
{"field_title": "创建时间", "field_type": "FIELD_TYPE_TEXT"}
]}'
Step 3: Save the configuration to memory
Save the following information to the memory file multi-agent-dev-config.md:
---
name: multi-agent-dev-config
description: 多代理协同智能表格配置信息
type: project
---
## 多代理协同表配置
- docid: <DOCID>
- url: <创建时返回的URL>
- 表格名称: 多代理开发任务
- 开发任务 sheet_id: <SHEET_ID>
- 竞赛记录 sheet_id: <SHEET_ID>
Operation Process
In the following commands,
<DOCID>and each<SHEET_ID>are read from multi-agent-dev-config in memory.
Mode 1: Competition Mode
The same task is assigned to 2-3 agents to complete independently, and the AI compares and selects the best solution.
Applicable scenarios: Need the optimal solution, architecture selection, algorithm implementation
Interaction flow:
- User: "Use competition mode to help me implement a user login module, with two agents each writing one version"
- AI records the task in the smart sheet
- Use Agent Tool to launch 2 sub-agents (
subagent_type: "general-purpose") - The two agents each complete the implementation
- AI compares the two solutions, scores them, and selects the best
- Send the result to the message
Agent Tool call example:
使用 Agent Tool 并行启动 2 个 general-purpose 子代理:
代理1 Prompt:实现一个用户登录模块。要求:
- 使用 JWT + Refresh Token 方案
- 包含密码强度校验
- 包含输入验证和错误处理
- 代码规范、有注释
代理2 Prompt:实现一个用户登录模块。要求:
- 使用 Session-based 方案
- 包含密码强度校验
- 包含输入验证和错误处理
- 代码规范、有注释
Record result:
# 记录各代理任务
wecom-cli doc smartsheet_add_records '{"docid": "<DOCID>", "sheet_id": "<开发任务SHEET_ID>", "records": [
{"values": {"任务描述": [{"type":"text","text":"用户登录模块"}], "工作模式": [{"text":"竞赛"}], "分配代理": [{"type":"text","text":"Agent1"}], "状态": [{"text":"已完成"}], "结果摘要": [{"type":"text","text":"JWT方案,完整性好"}], "耗时": [{"type":"text","text":"45s"}], "创建时间": [{"type":"text","text":"2026-04-02"}]}},
{"values": {"任务描述": [{"type":"text","text":"用户登录模块"}], "工作模式": [{"text":"竞赛"}], "分配代理": [{"type":"text","text":"Agent2"}], "状态": [{"text":"已完成"}], "结果摘要": [{"type":"text","text":"Session方案,简洁"}], "耗时": [{"type":"text","text":"38s"}], "创建时间": [{"type":"text","text":"2026-04-02"}]}}
]}'
# 记录竞赛对比
wecom-cli doc smartsheet_add_records '{"docid": "<DOCID>", "sheet_id": "<竞赛记录SHEET_ID>", "records": [{"values": {
"任务描述": [{"type":"text","text":"用户登录模块"}],
"代理1方案": [{"type":"text","text":"JWT + Refresh Token,完整性好"}],
"代理1评分": [{"type":"text","text":"8.5"}],
"代理2方案": [{"type":"text","text":"Session-based,简洁清晰"}],
"代理2评分": [{"type":"text","text":"7.0"}],
"推荐方案": [{"text":"代理1"}],
"对比分析": [{"type":"text","text":"JWT方案更符合现代最佳实践,Session方案更简洁但缺少密码强度校验"}],
"创建时间": [{"type":"text","text":"2026-04-02"}]
}}]}'
Mode 2: Division-of-Labor Mode
Different tasks are assigned to different agents for parallel execution.
Applicable scenarios: Multiple independent tasks, batch bug fixes, parallel feature development
Interaction flow:
- User: "I have 3 tasks to do in parallel: fix bug #123, write the login page, optimize the SQL query"
- AI launches one sub-agent for each task
- All agents execute in parallel
- Summarize the results
Agent Tool call:
并行启动 3 个 general-purpose 子代理:
代理1:修复 bug #123 — <具体 bug 描述>
代理2:写登录页面 — <具体需求>
代理3:优化 SQL 查询 — <具体优化目标>
Record result:
wecom-cli doc smartsheet_add_records '{"docid": "<DOCID>", "sheet_id": "<开发任务SHEET_ID>", "records": [
{"values": {"任务描述": [{"type":"text","text":"修bug #123"}], "工作模式": [{"text":"分工"}], "分配代理": [{"type":"text","text":"Agent1"}], "状态": [{"text":"已完成"}], "耗时": [{"type":"text","text":"45s"}], "创建时间": [{"type":"text","text":"2026-04-02"}]}},
{"values": {"任务描述": [{"type":"text","text":"写登录页面"}], "工作模式": [{"text":"分工"}], "分配代理": [{"type":"text","text":"Agent2"}], "状态": [{"text":"已完成"}], "耗时": [{"type":"text","text":"120s"}], "创建时间": [{"type":"text","text":"2026-04-02"}]}},
{"values": {"任务描述": [{"type":"text","text":"优化SQL查询"}], "工作模式": [{"text":"分工"}], "分配代理": [{"type":"text","text":"Agent3"}], "状态": [{"text":"已完成"}], "耗时": [{"type":"text","text":"60s"}], "创建时间": [{"type":"text","text":"2026-04-02"}]}}
]}'
Send summary notification:
wecom-cli msg send_message '{"chat_type": 1, "chatid": "<USERID>", "msgtype": "text", "text": {"content": "分工任务全部完成!\n\n| 任务 | 代理 | 状态 | 耗时 |\n|------|------|------|------|\n| 修bug #123 | Agent1 | 完成 | 45s |\n| 写登录页面 | Agent2 | 完成 | 120s |\n| 优化SQL查询 | Agent3 | 完成 | 60s |\n\n总耗时 120s(串行需 225s,加速 1.9x)"}}'
Mode 3: Pipeline Mode
Code → review → test, completed in sequence by different agents collaborating.
Applicable scenarios: Complex feature development, tasks requiring quality assurance
Interaction flow:
- User: "Use pipeline mode to help me refactor this module"
- Agent 1: Implement/refactor the code
- Agent 2: Code review, propose improvement suggestions
- Agent 3: Add tests (optional)
- Summarize the results
Agent Tool call:
按顺序启动 3 个子代理(注意:流水线是串行的,不是并行):
阶段1 代理:重构 <模块名> 模块的代码。要求:<具体要求>
阶段2 代理(接收阶段1结果):对以下代码进行审查。要求:
- 检查代码质量、潜在 bug、性能问题
- 提出 3-5 个改进建议
- 评估代码可维护性
阶段3 代理(接收阶段1+2结果):为以下代码编写完整的单元测试。要求:
- 覆盖所有主要功能路径
- 包含边界情况测试
Comparison of the Three Modes
| Mode | Applicable scenarios | Number of agents | Execution method | Speedup ratio |
|---|---|---|---|---|
| Competition | Need the optimal solution | 2-3 | Same task, completed separately, AI comparison | 1x (take the slowest) |
| Division of labor | Multiple independent tasks | By number of tasks | Different tasks, completed in parallel | Nx |
| Pipeline | Complex features, require quality assurance | 2-3 | Code → review → test, sequential collaboration | ~0.7x (with review overhead) |
Field type write format (general rules)
For the complete field type format description, see crm-schema
| Field type | Write format | Example |
|---|---|---|
| TEXT | [{"type":"text","text":"值"}] |
Task description, agent name, duration, etc. |
| SINGLE_SELECT | [{"text":"选项文本"}] |
Work mode, status, recommended solution, etc. |
Practical notes
Common pitfalls
- Not passing key_type when updating — must include
"key_type": "CELL_VALUE_KEY_TYPE_FIELD_TITLE" - When an API call fails — check the error code: 301085 means the docid is invalid (use url instead); 2022004 means the field was not found (call add_fields first); 2022003 means the record does not exist (call add_records first). When encountering an error, first use
smartsheet_get_sheet '{"url": "<URL>"}'to verify the table structure. - Agent Tool isolation — the two agents in competition mode need to work independently in
isolation: "worktree"to avoid interfering with each other - Pipeline serial dependency — in pipeline mode, the prompts for stages 2 and 3 need to include the output of stage 1
- Task granularity — each task in division-of-labor mode should be sufficiently independent to avoid cross-dependencies
- Agent count limit — it is recommended to start at most 3 agents at the same time to avoid resource contention
- options do not take effect when creating SINGLE_SELECT —
smartsheet_add_fieldspassed inproperty.optionswill not pre-create options; options are automatically created via[{"text": "选项"}]when a record is first written. When creating the field, thepropertyparameter can be omitted.
Data linkage
- This Skill runs independently and does not depend on other workflow Skills
- Use the underlying
wecom-cli todoto create tracking to-dos (optional) - Use the underlying
wecom-cli msgto send notifications