GPT WORLD / INDEPENDENT CODEX FIELD MANUAL 來源檢視 · 2026-07-26

實作指南 / 19 分鐘

從 Subagents 擴展到安全 Automation

先平行獨立 evidence,再把穩定 workflow 移入 codex exec 與 CI。

軌道
Codex CLI 核心
程度
自動化
成熟度
Stable core; custom-agent authoring may evolve

Subagents 把 noisy exploration 移出 main thread,適合平行 independent read-heavy work。codex exec 預設 read-only,progress 到 stderr、final message 到 stdout;JSONL/schema 支援 machine consumer。GitHub Actions 應使用官方 action 與最小權限。

CLI

已驗證 Terminal Sequence

TERMINAL / 刻意複製
  1. /agent
  2. $codex exec "summarize the repository structure"
  3. $codex exec --ephemeral "triage this repository"
  4. $codex exec --json "summarize the repo structure" | jq
  5. $codex exec resume --last "continue the task"
A

工作原則

01

平行 independent work

先做 exploration、tests、triage、review;parallel writes 需 file ownership/coordination。

02

Child 繼承 boundary

Subagents 繼承 parent sandbox/live overrides,先設權限再 spawn。

03

只 automate 穩定 contract

Prompt、inputs、permissions、output、failure handling 可重複後才進 codex exec。

B

實地程序

  1. 01

    Delegate bounded reads

    每個 independent concern 一個 agent,wait all,回 concise evidence。

  2. 02

    檢查 agent threads

    用 /agent 讀 status/result,不把 raw logs 塞 main context。

  3. 03

    以 codex exec prototype

    先 read-only/ephemeral,piped context 有界。

  4. 04

    加入 machine output

    --json 事件流或 --output-schema final object;repo state 相容才 resume。

  5. 05

    Harden CI

    使用 openai/codex-action@v1、trusted triggers、minimal permissions、isolated secrets、separate write job。

PASS / FAIL

驗收清單

  • Subtasks independent/bounded。
  • Parent permission least privilege。
  • Automation 處理 non-zero/malformed output。
  • Repo write credential 與 Codex job 隔離。

WATCH / REJECT

失敗模式

  • 為 tightly coupled writes spawn agents。
  • 新 script 使用 deprecated --full-auto。
  • Job-wide 暴露 API key 給 repo code。