多 Agent 协作
wescode 的多 Agent 协作模型:编程场景下的任务委派与分工。
编程场景的 Agent 角色
| Agent | 职责 | 典型工具集 |
|---|---|---|
| 主 Agent | 代码编写、重构 | read/write/edit/exec/grep |
| 代码审查 Agent | Review 代码变更 | read/grep/search_files |
| 测试 Agent | 编写和执行测试 | read/write/exec |
| 调试 Agent | 诊断和修复 Bug | read/exec/grep |
| 文档 Agent | 生成文档 | read/write |
委派机制
通过 wesgine delegate_task 工具实现:
主 Agent
├── delegate_task(goal="审查这段代码的安全性")
│ └── 子 Agent(只读工具集)
├── delegate_task(goal="为这个函数写单元测试")
│ └── 子 Agent(read + write + exec)
└── delegate_task(background=true, goal="运行完整测试套件")
└── 后台 Agent
Actor 传播
子 Agent 继承父 Agent 的 Actor:
tool.go把tc.Actor写进pp.Actor+pp.Tags["actor"]- 子 Run 的记忆写入、配额消耗归属到正确的 actor
CycleDetect 覆盖
委派子 Run 可用更严格阈值:
AppRunRequest{
CycleDetectOverride: &CycleDetectConfig{
ActionTermThreshold: 40,
IdenticalCallTermThreshold: 5,
},
}
深度限制
delegation.max_spawn_depth(默认 2)防止无限委派:
主 Agent(depth=0)
└── 子 Agent(depth=1)
└── 孙 Agent(depth=2)← 不能再委派
并发控制
- 同一 Cell 同一 Session 同一时刻最多一个 Run
- 批量委派(
tasks: [...])并发受max_concurrent_children限制 - 后台委派(
background=true)结果异步回注
与 wescode 的特殊关系
wescode 通过 CellSpec hook 增强委派:
- 子 Agent 继承 HostEnvironment(Buffer Overlay)
- 子 Agent 共享 CKG 索引
- 子 Agent 工具集可定制(如只给审查 Agent 只读工具)
相关文档
- wesgine 委派模型 → engine
delegation-model.md - Actor 边界 → engine
actor-boundary.md - 工作区即 Cell →
workspace-cell.md