AI Learn
OpenAI Codex · Practical Tutorial

Run a parallel Codex subagent review without creating edit conflicts

Delegate independent review angles to subagents, keep them read-only during discovery, then let the main Codex thread consolidate evidence before any fix.

Reviewed September 20, 2026Independent tutorialFeatures may vary
Not official support. AI Learn is an independent education site. Check the provider’s current documentation for plan-specific limits, pricing and feature availability.
Before you start

Subagents are best for independent exploration, tests, triage and review. Parallel writing to the same files creates coordination cost and conflicts, so keep the discovery phase read-only unless work is explicitly partitioned.

1. Define independent review dimensions such as security, tests and maintainability

Define review axes that are genuinely independent—security boundaries, missing tests and maintainability are better than three agents all asked to “review the code.” Independence reduces duplicated findings.

2. Ask Codex to spawn one subagent per dimension and wait for all of them

Create one subagent per axis and make the parent wait for all of them. Give each agent the same target diff and forbid edits so their outputs remain comparable and cannot race on shared files.

3. Require file references, evidence and uncertainty from every subagent

Require file/line references, evidence, severity and uncertainty for every finding. A vague concern without a concrete path should be treated as a question to investigate, not as a defect.

4. Keep shared-code edits disabled during the parallel review

Keep the parallel phase read-only. If an agent wants to test a hypothesis, let it run tests or inspect files, but route any code changes back through the parent after synthesis.

5. Let the main thread deduplicate findings, resolve contradictions and choose the fixes

Deduplicate findings in the parent, resolve contradictions and choose fixes based on evidence and impact. Preserve minority findings when they point to a plausible high-severity failure that still needs checking.

Try this prompt

Review this branch with parallel Codex subagents. Spawn one read-only agent for security, one for test gaps and one for correctness/regressions. Wait for all three. Each finding needs file references and a concrete failure case. The main thread should deduplicate and rank findings before any edits.

Common mistakes

Spawning several agents to edit the same files; using agents for dependent steps; no evidence requirement; summarizing before all agents return; turning every observation into a patch.

Finish check

The final review contains a deduplicated set of evidence-backed findings, you can open individual agent threads if needed, and no code changed during discovery.

开始之前

子智能体最适合独立探索、测试、分诊和审查。多个智能体同时写同一批文件会制造冲突和协调成本,因此调查阶段最好只读,除非修改范围已经明确分区。

1. 把审查拆成安全、测试、可维护性等互相独立的维度

先定义真正独立的 Review 维度,例如安全边界、测试缺口、可维护性;不要让 3 个 Agent 都收到“帮我 Review 一下代码”的同样任务。维度独立才能减少重复发现。

2. 要求 Codex 每个维度启动一个子智能体,并等待全部完成

每个维度使用一个子智能体,并让主任务等待全部返回。所有 Agent 看同一个目标 Diff,同时禁止直接编辑,这样结果可比较,也不会并行抢改共享文件。

3. 要求每个子智能体都返回文件位置、证据和不确定性

每个 Finding 都必须带文件/行号、证据、严重度和不确定性。只有模糊担忧却没有具体路径时,应把它当成待调查问题,而不是已经确认的缺陷。

4. 并行审查阶段不要修改共享代码

并行阶段保持只读。Agent 可以跑测试或查看文件来验证假设,但任何代码修改都应等主任务汇总以后再统一进入修复阶段。

5. 让主线程去重发现、解决矛盾,再选择真正要修的问题

最后由主任务去重、解决矛盾,并根据证据和影响决定修哪些问题。少数意见如果指向潜在高严重度风险,也要保留下来继续验证,不要按“多数票”删除。

可以直接套用的提示词

用 Codex 子智能体并行审查这个分支:一个只读智能体看安全,一个看测试缺口,一个看正确性/回归。等待三个都完成。每条发现必须有文件引用和具体失败场景。主线程先去重和排序,再决定是否修改。

常见错误

多个智能体同时改同一文件;把强依赖步骤拆并行;不要求证据;部分智能体没返回就先总结;把所有观察都变成补丁。

完成检查

最终审查只保留去重后的证据型发现,必要时可以查看单个智能体线程,而且调查阶段没有修改代码。

開始之前

子智能體最適合獨立探索、測試、分診和審查。多個智能體同時寫同一批檔案會製造衝突和協調成本,因此調查階段最好只讀,除非修改範圍已經明確分區。

1. 把審查拆成安全、測試、可維護性等互相獨立的維度

先定義真正獨立的 Review 維度,例如安全邊界、測試缺口、可維護性;不要讓 3 個 Agent 都收到“幫我 Review 一下代碼”的同樣任務。維度獨立才能減少重復發現。

2. 要求 Codex 每個維度啓動一個子智能體,並等待全部完成

每個維度使用一個子智能體,並讓主任務等待全部返回。所有 Agent 看同一個目標 Diff,同時禁止直接編輯,這樣結果可比較,也不會並行搶改共享檔案。

3. 要求每個子智能體都回傳檔案位置、證據和不確定性

每個 Finding 都必須帶檔案/行號、證據、嚴重度和不確定性。只有模糊擔憂卻沒有具體路徑時,應把它當成待調查問題,而不是已經確認的缺陷。

4. 並行審查階段不要修改共享程式碼

並行階段保持只讀。Agent 可以跑測試或查看檔案來驗證假設,但任何代碼修改都應等主任務匯總以後再統一進入修復階段。

5. 讓主線程去重發現、解決矛盾,再選擇真正要修的問題

最後由主任務去重、解決矛盾,並根據證據和影響決定修哪些問題。少數意見如果指向潛在高嚴重度風險,也要保留下來繼續驗證,不要按“多數票”刪除。

可以直接套用的提示詞

用 Codex 子智能體並行審查這個分支:一個只讀智能體看安全,一個看測試缺口,一個看正確性/回歸。等待三個都完成。每條發現必須有檔案引用和具體失敗場景。主線程先去重和排序,再決定是否修改。

常見錯誤

多個智能體同時改同一檔案;把強依賴步驟拆並行;不要求證據;部分智能體沒回傳就先總結;把所有觀察都變成補丁。

完成檢查

最終審查只保留去重後的證據型發現,必要時可以查看單個智能體線程,而且調查階段沒有修改程式碼。

Official references

Check current product details at the source

Related practical tutorials

Continue with another single-task workflow.

All tutorials →