Codex 可以通过并行 spawning specialized agents 来运行 subagent workflows,让它们同时 explore、tackle 或 analyze work。
本页解释 core concepts 和 tradeoffs。关于 setup、agent configuration 和 examples,请参见 Subagents 。
为什么 subagent workflows 有帮助
即使 context windows 很大,models 也有 limits。如果你把 exploration notes、test logs、stack traces 和 command output 等 noisy intermediate output 填进 main conversation(你定义 requirements、constraints 和 decisions 的地方),session 会随着时间推移变得不那么可靠。
这通常被描述为:
Context pollution:有用信息被 noisy intermediate output 淹没。
Context rot:conversation 填满较不相关的细节后,performance 下降。
背景信息可参见 Chroma 关于 context rot 的 writeup。
Subagent workflows 通过把 noisy work 移出 main thread 来提供帮助:
让 main agent 聚焦于 requirements、decisions 和 final outputs。
并行运行 specialized subagents,用于 exploration、tests 或 log analysis。
从 subagents 返回 summaries,而不是 raw intermediate output。
当 work 可以独立并行运行时,它们还可以节省时间,并通过把 larger-shaped tasks 拆成 bounded pieces,让任务更易处理。例如,Codex 可以把 multi-million-token document 的 analysis 拆成更小的问题,并把 distilled takeaways 返回给 main thread。
作为起点,请将 parallel agents 用于 read-heavy tasks,例如 exploration、tests、triage 和 summarization。对于 parallel write-heavy workflows 要更谨慎,因为 agents 同时编辑 code 会产生 conflicts,并增加 coordination overhead。
核心术语
Codex 在 subagent workflows 中使用几个相关术语:
Subagent workflow:Codex 运行 parallel agents 并合并其 results 的 workflow。
Subagent:Codex 启动的 delegated agent,用于处理某个 specific task。
Agent thread:某个 agent 的 CLI thread,你可以使用 /agent inspect 并在它们之间切换。
触发 subagent workflows
Codex 不会自动 spawn subagents,并且只应在你明确要求 subagents 或 parallel agent work 时使用 subagents。
实践中,manual triggering 意味着使用直接 instructions,例如 “spawn two agents”、“delegate this work in parallel” 或 “use one agent per point”。Subagent workflows 比可比的 single-agent runs 消耗更多 tokens,因为每个 subagent 都会执行自己的 model 和 tool work。
好的 subagent prompt 应说明如何划分工作、Codex 是否应等待所有 agents 后再继续,以及要返回什么 summary 或 output。
Review this branch with parallel subagents. Spawn one subagent for security risks, one for test gaps, and one for maintainability. Wait for all three, then summarize the findings by category with file references. 选择 models 和 reasoning
不同 agents 需要不同的 model 和 reasoning settings。
如果你没有 pin model 或 model_reasoning_effort,Codex 可以选择一种在 intelligence、speed 和 price 之间平衡的 setup。它可能会为 fast scans 偏向 gpt-5.4-mini,或为更 demanding reasoning 选择 higher-effort gpt-5.5 configuration。当你希望更细粒度控制时,可以在 prompt 中 steer 这个选择,或直接在 agent file 中设置 model 和 model_reasoning_effort。
对于 Codex 中的大多数 tasks,请从 gpt-5.5 开始。当你希望为较轻量 subagent work 使用更快、成本更低的选项时,使用 gpt-5.4-mini。如果你有 ChatGPT Pro,并希望获得近乎即时的 text-only iteration,gpt-5.3-codex-spark 仍以 research preview 形式可用。
Model choice
gpt-5.5:为 demanding agents 从这里开始。它最适合 ambiguous、multi-step work,需要 planning、tool use、validation,并在更大 context 中 follow-through。
gpt-5.4:当 workflow pinned to GPT-5.4 时使用。它结合了 strong coding、reasoning、tool use 和 broader workflows。
gpt-5.4-mini:用于偏向 speed 和 efficiency 而非 depth 的 agents,例如 exploration、read-heavy scans、large-file review 或 processing supporting documents。它适合返回 distilled results 给 main agent 的 parallel workers。
gpt-5.3-codex-spark:如果你有 ChatGPT Pro,当 latency 比 broader capability 更重要时,可将此 research preview model 用于近乎即时的 text-only iteration。
Reasoning effort(model_reasoning_effort)
high:当 agent 需要 trace complex logic、check assumptions,或处理 edge cases 时使用(例如 reviewer 或 security-focused agents)。
medium:多数 agents 的 balanced default。
low:当 task 很直接且 speed 最重要时使用。
更高 reasoning effort 会增加 response time 和 token usage,但可能提升 complex work 的质量。详情请参见 Models 、 Config basics 和 Configuration Reference 。