October 23, 2026

子智能体与并行智能体:有什么区别?

子智能体是 AI 编程智能体在自己的会话中启动的助手,负责任务中的某一部分,完成后汇报结果。并行智能体则是相互独立的多个会话,每个会话同时负责一个完整的任务。下面介绍 Claude Code 子智能体如何工作、它们与并行智能体有何不同,以及各自适用的场景。

简短回答

  • 子智能体拆分的是一个任务。主智能体把一项聚焦的工作(例如搜索代码库或审查 diff)交给拥有独立上下文窗口的子智能体。子智能体返回摘要,主智能体继续工作。
  • 并行智能体拆分的是整体工作。你运行多个相互独立的智能体会话,每个会话执行自己的任务,通常各自位于独立的 git worktree 中,然后审查每个会话的产出。

大多数实际工作流会同时使用两者:多个并行智能体,每个智能体在工作过程中再使用子智能体。

AI 编程中的子智能体是什么?

用 Anthropic 的话说,Claude Code 子智能体是“执行特定类型任务的专用 AI 助手”。每个子智能体都在自己的上下文窗口中运行,拥有自己的系统提示词、工具访问权限和权限设置。完成后,只有它的结果会返回主对话,因此繁杂的中间工作(数十次文件读取、冗长的测试日志)不会进入主智能体的上下文。

Codex 也采用了同样的思路:它可以“并行生成专用智能体,然后将它们的结果汇总到一个回复中”。

Claude Code 子智能体如何工作

内置子智能体。 Claude Code 自带:

  • Explore,一个快速、只读的智能体,用于搜索和分析代码库。
  • Plan,一个研究型智能体,在计划模式下先收集上下文,再给出计划。
  • General-purpose,用于既需要探索又需要执行操作的复杂多步骤任务。

自定义子智能体。 子智能体就是一个带有 YAML frontmatter 的 Markdown 文件。把它放在 .claude/agents/ 中,可与项目中的所有人共享;放在 ~/.claude/agents/ 中,则可在你的所有项目中使用。只有 name 和 description 是必填项:

---
name: code-reviewer
description: Reviews code for quality and best practices
tools: Read, Glob, Grep
model: sonnet
---

You are a code reviewer. When invoked, analyze the code and provide
specific, actionable feedback on quality, security, and best practices.

description 告诉 Claude 何时将工作委派给该子智能体,tools 限制它可以使用的工具,model 指定它运行所用的模型。

前台与后台。 前台子智能体会阻塞主对话,直到它完成。后台子智能体在你继续工作时运行,其结果会在之后的某一轮中以通知形式送达。

嵌套与隔离。 默认情况下,子智能体可以启动自己的子智能体,最多可达主对话以下三层。子智能体在主对话的工作目录中启动;如果在其 frontmatter 中设置 isolation: worktree,则会为它提供一个临时 git worktree,其中包含独立的仓库副本。

Codex 子智能体如何工作

Codex 将自定义智能体定义为 TOML 文件,存放在 ~/.codex/agents/(个人)或 .codex/agents/(项目)中。每个文件设置 name、description 和 developer_instructions。Codex 还自带名为 default、worker 和 explorer 的内置智能体。子智能体在各自的智能体线程中工作,继承父级的沙箱和审批设置,并将摘要返回主线程。OpenAI 的文档建议将它们用于并行探索、测试和日志分析。

什么是并行智能体?

并行智能体是编程智能体的多个独立会话,每个会话同时执行不同的任务。每个会话都有自己的对话、自己的上下文窗口和自己的目标,你可以直接与每个会话交流。

常见的设置方式:

  1. 每个智能体一个任务,并让这些任务涉及不同的文件。
  2. 每个智能体一个检出副本,通常是一个位于独立分支上的 git worktree,这样每个智能体的修改都留在自己的分支上。
  3. 每个结果一次审查,在分支准备就绪时合并。

Claude Code 通过 claude --worktree、后台智能体和智能体团队支持这种方式。Codex 则通过多个本地会话、codex --worktree 和云端任务来支持。Claude Squad、Vibe Kanban 和 Chief 等工具可以帮助你同时运行和跟踪多个会话。分步说明请参阅如何并行运行多个 Claude Code 智能体。

子智能体与并行智能体一览

子智能体并行智能体
拆分对象将一个任务拆分为聚焦的子工作将一个项目拆分为独立的任务
由谁启动主智能体,在其决定委派时你,或一个编排工具
上下文独立的上下文窗口;向父级返回摘要独立的会话,并拥有整个任务的完整上下文
你与谁交流仅主智能体直接与每个智能体交流
工作副本默认使用父级的目录(isolation: worktree 可获得副本)通常是独立的 git worktree 或分支
生命周期子工作完成即结束一直运行到任务完成
配置位置.claude/agents/ 或 .codex/agents/你的终端、worktree 或编排工具
最适合在一个任务内部进行研究、搜索、审查和测试运行同时发布多个功能或修复

何时使用子智能体

Anthropic 的文档建议在以下情况使用子智能体:

  • 任务会产生大量输出,而你的主上下文并不需要这些输出,例如代码库搜索或长时间的测试运行。
  • 你需要特定的工具限制或权限,例如只读的审查者。
  • 工作是自成一体的,可以以摘要形式返回。

如果任务需要频繁来回沟通,或者规划、实现和测试共享大量上下文,又或者你只是在做一次快速、有针对性的修改,那就留在主对话中。

何时使用并行智能体

在以下情况下选择并行智能体:

  • 独立的工作量超出了一个会话的能力,例如三个 bug 修复加一个新端点。
  • 工作无法装进一个上下文窗口,或者需要在你做其他事情时持续运行。
  • 你希望在不同任务上使用不同的智能体或模型,例如让 Claude Code 负责重构,让 Codex 负责测试。

并行智能体的代价是协调:选择不会相互冲突的任务,跟踪哪个智能体正在等你,以及审查每一个结果。

Chief 如何为你运行并行智能体

Chief 是一个 AI 智能体管理器。它承担并行智能体周边的协调工作,让你可以专注于决策。

  • 你设定目标,Chief 规划工作。 Chief 将目标拆分为多个里程碑,每个里程碑都有完成标准,并标明它所依赖的里程碑。
  • 按计划并行。 Chief 会同时运行所有依赖已完成的里程碑。它会先规划类型和迁移等共享部分,并将会修改相同文件的工作串联起来,让并行智能体互不干扰。
  • 你的子智能体随之可用。 每个里程碑都作为独立的智能体会话在你的项目文件夹中运行,因此你保存在 .claude/agents/ 或 .codex/agents/ 中的子智能体可供智能体使用。
  • 在你的电脑上运行,使用你的订阅。 Chief 中继在你的机器上启动 Claude Code、Codex 和其他智能体,并使用你自己的账户登录。
  • 每个结果都经过审查。 Chief 对照完成标准检查每个里程碑,并将只有你才能做出的决策汇集到一个队列中。

让 Chief 运行你的并行智能体。免费开始 →


常见问题

子智能体和智能体有什么区别?

智能体是你直接与之协作的完整会话。子智能体是智能体在自己的会话中为某项聚焦工作启动的助手。它拥有自己的上下文窗口,并向启动它的智能体返回摘要。

Claude Code 子智能体能并行运行吗?

它们可以并行运行。Claude Code 可以同时运行多个子智能体,后台子智能体会在你继续工作时运行。不过,它们仍属于同一个会话,结果也都会返回同一个主对话。

Claude Code 子智能体文件应该放在哪里?

针对单个项目的子智能体放在 .claude/agents/ 中(将其提交到版本控制,以便团队使用);可在你所有项目中使用的个人子智能体放在 ~/.claude/agents/ 中。

我应该使用子智能体还是并行智能体?

用子智能体保持单个任务的上下文整洁:研究、搜索、审查和测试运行。用并行智能体同时完成更多独立任务。大多数团队两者都用。

Chief 会取代 Claude Code 子智能体吗?

不会。Chief 在更高一层工作:它规划并并行运行相互独立的智能体会话。在每个会话内部,Claude Code 或 Codex 仍然可以使用自己的子智能体。

More articles

AI Agent Orchestration Guide

What AI agent orchestration is, how multi-agent orchestration works for Claude Code and Codex, and a comparison of orchestration approaches. Free guide.

What Is Agentic Engineering?

Agentic engineering means directing AI coding agents that write and test code while you set goals and review results. How it differs from agentic coding.

AI Code Review at Scale

What AI code review is, the main types of AI code review tools, and five workflows for reviewing AI-generated code from several coding agents at once.

Claude Code and Codex Pricing

Claude Code pricing from $20/mo (Pro) to $200/mo (Max 20x), Codex pricing from ChatGPT Free to Pro, usage limits and a comparison table, checked Oct 2026.

From Single Agent to Multi-Agent

Already using one AI coding agent? Here's how to scale to multiple instances running in parallel — the concurrency patterns, worktree isolation, and task decomposition strategies that make it work.

Vibe Coding at Scale

Vibe coding with one agent is fun. Vibe coding with five is chaos — unless you have orchestration. Here's how to scale the vibe without losing the quality.

Why AI Agents Need an Orchestration Layer

Running AI coding agents in terminal tabs works for two. Five signs you've outgrown it, tabs vs an orchestration layer, and what to look for in one.

Multi-Provider AI Orchestration

Claude Code, Codex, Cursor, Aider — each excels at different work. Here's how to combine providers into one coordinated workflow and why cross-provider review catches bugs single-provider setups miss.

Use Chief From Your AI Assistant

Add Chief's remote MCP server to Claude, Claude Code or Codex. Ask what's waiting on you, catch up on what shipped and propose milestones from chat.

Claude Code vs Codex: When to Use Each

Codex vs Claude Code: when each fits, a comparison table and FAQ. Claude Code vs Codex isn't either-or; Chief runs both on your projects.

Claude Code vs Cursor: When to Use Each

Cursor vs Claude Code: when each fits, a comparison table and FAQ. Claude Code vs Cursor isn't either-or; keep Cursor and let Chief run Claude Code.

How to Run Multiple Claude Code Agents in Parallel

Run multiple Claude Code agents in parallel, step by step: worktrees, background agents, subagents and review. Then let Chief orchestrate them for you.

Git Worktrees for AI Coding Agents

How to use git worktrees with Claude Code and Codex: one per agent, parallel runs, .env files, merging and cleanup. Every command, step by step.

How to Run Claude Code From Your Phone

Run Claude Code from your phone: Remote Control, cloud sessions in the Claude mobile app, or SSH and tmux, step by step. Plus approving agents in Discord.

The Best AI Coding Agents in 2026

The best AI coding agents of 2026: Claude Code, Codex, Cursor, Copilot and more agentic AI coding tools compared, and how to run several with Chief.

How to Install and Set Up Codex CLI

Install Codex CLI on macOS, Linux or Windows, sign in, run your first session and update it. Every command, then run Codex alongside Claude Code in Chief.

Ready to manage your agents?

_Claude Code 是 Anthropic 的商标。Codex 是 OpenAI 的商标。Chief 是一款独立产品,与上述两家公司均无关联,也未获得其赞助或认可。_