Knowledges 2 分钟
Claude Code Sub Agents:从失望到效率最大化
Claude Code 的 Sub Agents 又慢又烧 token,结果还不见得更好?问题在于我们用错了地方:它们是用来调研和收集 context 的,而不是替主 agent 写代码。
其他语言: English · Tiếng Việt · 한국어 · 日本語
Sub Agents 最初的问题
Claude Code 刚推出 Sub Agents 功能时,很多人(包括我)都遇到过这种情况:
慢吞吞
比主 agent 慢了一大截。
狂烧 token
token 像流水一样哗哗地花。
结果没更好
跟直接让主 agent 全包相比,没好到哪去。
之所以这样,是因为我们大多数人都误解了 Sub Agents 的设计初衷。
为什么 Claude Code 需要 Sub Agents?
Claude Code agent 依靠一系列 tools 工作:读文件、列文件、改文件…… 问题在于 read tool 可能一下“吃掉”上千个 tokens,因为它要把整个文件内容塞进 conversation history。
| 没有 Sub Agents 之前 | Sub Agents 的设计目的 |
|---|---|
| 主 agent 读大量文件 → 占用 80% 的 context window | 把调研任务 delegate 给辅助 agent |
| 触发 “compact conversation” → 对话被压缩总结 | 辅助 agent 独立工作,只返回简短的 summary |
| 因为丢失 context,performance 大幅下降 | 主 agent 拿到的是浓缩信息,而不是 raw data |
常见误区:用 Sub Agents 来做 implementation
很多人(包括一开始的我)是这么想的:
- Frontend Dev Agent → 负责前端
- Backend Dev Agent → 负责后端
- Parent Agent → 只负责 orchestrate
锁定章节: Best Practice:把 Sub Agents 当成收集 context 的大军
锁定章节: 高效 Sub Agents 示例
锁定章节: Context Management:用文件系统当记忆
锁定章节: 目录结构
锁定章节: Workflow
锁定章节: 实战演示:ChatGPT Clone
锁定章节: ShadCN Expert
锁定章节: Vercel AI SDK Expert
锁定章节: Parent Agent
锁定章节: 要点总结
其余内容仅限 Knowledges 会员
另有 10 个章节(约 1 分钟)仅限会员
你正在阅读约前三分之一。Knowledges、组合和社区方案可阅读付费文章全文;Zuey AI 方案仅可阅读预览。