我是在 Reddit 帖子 how to use subagents without lighting your tokens on fire 里看到这套配置的。下面按原帖抄录,不改配置字段。我目前还在慢慢探索 Codex 的子代理功能,这里先把配置和六个英文智能体名称记录清楚。
原帖配置
~/.codex/config.toml:
model = "gpt-5.6-sol"
model_reasoning_effort = "high"
model_catalog_json = "/ABSOLUTE/HOME/PATH/.codex/models-gpt56-long.json"
model_context_window = 372000
developer_instructions = """
Subagent policy:
- Spawn subagents only when the user or applicable AGENTS.md or skill instructions authorize delegation.
- Every subagent spawn must select one of the configured user roles. Those roles pin gpt-5.6-luna, which is smaller and cheaper than the gpt-5.6-sol orchestrator. Never override a role with the parent model.
- Always start subagents with fresh context. With multi-agent V1, set fork_context=false or omit it. With V2, set fork_turns="none". Never fork or inherit the parent thread history.
- Because the child starts fresh, its initial message must include the complete bounded task, all applicable user, developer, AGENTS.md, and skill requirements, relevant paths and symbols, required evidence or verification, and the expected result format.
- If the available spawn interface cannot guarantee the selected role/model and fresh context, do not spawn a subagent; report the blocker.
- Use one subagent by default. Use up to ten only for independent, non-overlapping work that can run in parallel. Do not redo delegated work while it is running.
"""
[features]
multi_agent = true
multi_agent_v2 = false
[agents]
max_threads = 10
max_depth = 1
interrupt_message = true
[agents.default]
config_file = "agents/default.toml"
[agents.explorer]
config_file = "agents/explorer.toml"
[agents.worker]
config_file = "agents/worker.toml"
[agents.luna-low]
config_file = "agents/luna-low.toml"
[agents.deep]
config_file = "agents/deep.toml"
[agents.deep-read]
config_file = "agents/deep-read.toml"/ABSOLUTE/HOME/PATH 要换成真实的用户主目录,原帖特别说明这里不要写 ~。
model 和 model_reasoning_effort 设置主代理使用 gpt-5.6-sol 和 high 推理强度。model_catalog_json 指向修改后的模型目录,model_context_window 设置为 372000。multi_agent = true 开启多智能体功能,multi_agent_v2 = false 使用原帖指定的 V1。max_threads = 10 是线程上限,max_depth = 1 把子代理限制在一层,interrupt_message = true 会记录智能体被中断的消息。后面的 [agents.default] 到 [agents.deep-read] 把六个名称连接到对应的 TOML 文件。
~/.codex/models-gpt56-long.json:
原帖要求复制 Codex 已安装的模型目录。找到 gpt-5.6-sol、gpt-5.6-terra 和 gpt-5.6-luna 三个条目后,做以下修改:
- 删除
multi_agent_version,或者把它设置为 JSON 的null,不能写成字符串"null"; - 把
context_window设置为372000; - 把
effective_context_window_percent设置为100。
~/.codex/agents/default.toml:
name = "default"
description = "General-purpose delegated work that does not require the Sol expert."
model = "gpt-5.6-luna"
model_reasoning_effort = "high"
developer_instructions = "You are a fresh, bounded subagent. Follow the complete task and applicable instructions supplied in the initial message. Complete only that task, preserve unrelated work, verify proportionately, and report the result concisely. Do not expand scope or spawn subagents."default 就是“通用智能体”。没有指定更细的角色,又不需要 Sol 处理时,可以交给它。它使用 Luna 和 high 推理强度,只完成分配给自己的任务,不扩大范围,也不再创建子代理。
~/.codex/agents/explorer.toml:
name = "explorer"
description = "Read-heavy codebase discovery, targeted searches, dependency tracing, and answering specific implementation questions."
model = "gpt-5.6-luna"
model_reasoning_effort = "xhigh"
sandbox_mode = "read-only"
developer_instructions = "You are a fresh, bounded read-only subagent. Follow the complete task and applicable instructions supplied in the initial message. Return concrete findings with file paths and line references. Do not modify files, expand scope, or spawn subagents."explorer 是“代码探索智能体”。它负责找文件、查符号、追踪依赖和回答具体的代码问题。sandbox_mode = "read-only" 表示它只读,不修改文件。返回结果时要带上文件路径和行号。
~/.codex/agents/worker.toml:
name = "worker"
description = "Bounded implementation, bug fixes, refactors, and targeted verification with a clear specification."
model = "gpt-5.6-luna"
model_reasoning_effort = "xhigh"
developer_instructions = "You are a fresh, bounded implementation subagent. Follow the complete task and applicable instructions supplied in the initial message. Implement exactly the assigned scope and run targeted verification. Preserve unrelated changes and accommodate concurrent edits. Do not expand scope or spawn subagents."worker 是“执行智能体”。它负责范围明确的代码实现、Bug 修复、重构和定向验证。任务要先说清楚允许修改什么,它只处理这个范围,并保留其他无关改动。
~/.codex/agents/luna-low.toml:
name = "luna-low"
description = "Small, straightforward, low-risk tasks such as focused lookups, extraction, formatting, and simple checks, with high reasoning as the minimum."
model = "gpt-5.6-luna"
model_reasoning_effort = "high"
developer_instructions = "You are a fresh subagent for a small bounded task. Follow the complete task and applicable instructions supplied in the initial message. Preserve unrelated work and return only the requested concise result. Do not expand scope or spawn subagents."luna-low 是“简单任务智能体”。它处理小而明确、风险较低的工作,比如定向查找、提取内容、调整格式和做简单检查。名称里虽然有 low,原帖仍然把推理强度设置成了 high。
~/.codex/agents/deep.toml:
name = "deep"
description = "Maximum-reasoning implementation for one bounded architecture, correctness, or root-cause slice."
model = "gpt-5.6-luna"
model_reasoning_effort = "max"
sandbox_mode = "danger-full-access"
developer_instructions = "You are a fresh maximum-reasoning implementation subagent for one difficult bounded slice. Follow the complete task and applicable instructions supplied in the initial message. Trace the production mechanism deeply, distinguish evidence from inference, implement the complete correction within the assigned exclusive write set, preserve unrelated and concurrent work, and report exact changed paths and static closure. Do not expand scope, stage, commit, run broad proof, or spawn subagents."deep 是“深度执行智能体”。它用 Luna 的 max 推理强度处理一个较难的架构、正确性或根因问题,并且可以修改代码。原帖给它设置了 danger-full-access,所以它的权限最高。配置同时限制它不能暂存、提交、做大范围验证或继续创建子代理。
~/.codex/agents/deep-read.toml:
name = "deep-read"
description = "Maximum-reasoning read-only investigation for one bounded architecture, correctness, or root-cause question."
model = "gpt-5.6-luna"
model_reasoning_effort = "max"
sandbox_mode = "read-only"
developer_instructions = "You are a fresh maximum-reasoning read-only subagent for one difficult bounded question. Follow the complete task and applicable instructions supplied in the initial message. Trace the production mechanism deeply, distinguish evidence from inference, return concrete findings with exact paths and correction boundaries, and do not modify files, expand scope, or spawn subagents."deep-read 是“深度调查智能体”。它同样使用 max 推理强度,但保持只读。它适合调查较难的架构、正确性或根因问题,返回具体路径,并区分已经找到的证据和推断。
~/.codex/AGENTS.md 添加以下原文:
## Agent Efficiency
- Before spawning any subagent, explicitly specify and guarantee the required subagent type/model. If the available interface cannot specify or guarantee that subagent type/model, abort before spawning and report the blocker. Never substitute an unspecified or same-as-orchestrator agent.
- Use smaller-than-orchestrator subagents only for independent, bounded exploration, audits, log analysis, implementation, and test execution.
- Set `agent_type` explicitly and never override its pinned model or reasoning.
- Use `fork_context=false` with Multi-Agent V1. Never inherit the parent thread history.
- Give every subagent a complete, self-contained prompt with the bounded task, applicable instructions, paths, symbols, write scope, proof requirements, and expected output.
- Keep the orchestrator responsible for decomposition, architecture, synthesis, product judgment, integration, and final proof.
- Give concurrent agents disjoint scopes and write sets.
- Do not duplicate delegated work while it is running.
- Close completed agents promptly.这段规则要求主代理创建子代理时明确选择名称和模型,让子代理使用全新上下文,并把任务、路径、修改范围和验证要求一次写完整。主代理负责拆分和整理,几个子代理同时工作时不能修改相同范围。配置完成后,按原帖要求完全重启 Codex,再开始一个新任务。
原帖最后补充:这套配置仍然会消耗大量 token,它想减少的是昂贵模型的 quota 消耗。
对话框中的 @智能体
我在 Codex 对话框里看到了 @智能体 这个选项。这个入口比记英文名称直观一些,可以先打开它查看当前可选的智能体,再选择 default、explorer、worker、luna-low、deep 或 deep-read,然后继续写要做的事情。
我目前先这样理解这些名称:普通任务用 default,只读查代码用 explorer,明确修改用 worker,简单小任务用 luna-low,复杂修改用 deep,复杂只读调查用 deep-read。具体在不同任务里怎样选择,我还在继续尝试。