Knowledge Hubบทที่ 22
Updates · อัปเดตใหม่

Codex Team Dispatch (headless) + Dual-Layer Codex Fleet · สูตรโกง 10 coders ขนาน

วิวัฒน์ขั้นถัดจาก ch20: dispatch แบบ headless (codex exec ผ่าน background Agent, ไม่ต้อง tmux/charter) และ Dual-Layer Fleet 10 coders ขนาน (5 headless + 5 tmux) พร้อม traps จริง — cross-verify โดย fleet · The evolution past ch20: headless dispatch (codex exec via a background Agent, no tmux/charter) and a 10-coder dual-layer fleet (5 headless + 5 tmux) with the real traps — cross-verified by the fleet.

จากสูตร charter สู่ headless · From the charter recipe to headless dispatch

บทนี้ต่อยอดจาก ch20 (/codex-team lifecycle) ซึ่งเป็นสูตร charter + tmux. ใน session เดียวกัน (17 มิ.ย. 2026) P'Nut ดันสูตรไปอีกขั้น: เพิ่ม verb dispatch ที่รัน codex แบบ headless ผ่าน background Agent — ไม่ต้อง tmux, ไม่ต้อง charter. วิวัฒน์ทั้งสาย: ting → tee → arra → headless → dual-layer ในสัปดาห์เดียว.

This chapter extends ch20 (/codex-team lifecycle), the charter+tmux recipe. In the same 17 Jun 2026 session P'Nut pushed it further: a dispatch verb that runs codex headless via a background Agent — no tmux, no charter. The full evolution in one week: ting → tee → arra → headless → dual-layer.

5 verbs + สิ่งที่ session พิสูจน์ · The skill & what the session proved

/oracle-team มี 5 verbs; ตัวใหม่คือ dispatch (headless codex exec, tracked ผ่าน background Agent).

/oracle-team has five verbs; the new one is dispatch (headless codex exec, tracked via a background Agent).

Verbทำอะไร · Does
up [profile]tmux panes (long-term)
dispatch [issues]headless codex exec — background Agent, tracked ← ใหม่ · NEW
down [1,2,3]safe teardown
leadorchestrate cycle
statusread-only peek

สิ่งที่ session นี้พิสูจน์ (P'Nut + fleet cross-verify) · What this session proved:

DiscoveryDetail
Shell &harness มองไม่เห็น — อย่าใช้ · invisible to the harness — don't use
Agent(run_in_background=true)harness track + notify (the /forward-bg pattern)
Haiku wraps codex execwrapper ถูก ($0.25/M), งานจริงคือ codex (gpt-5.5) · cheap wrapper, real work is codex
Worktrees requiredcodex exec ไม่มี worktree = งานหายตอน exit · no worktree = changes lost on exit
maw hey callbackยิงจาก codex exec ได้ ไปโผล่ใน tmux · fires from codex exec, arrives in tmux
3 parallel coders920 lines committed, zero manual intervention

tmux เดิม vs codex exec headless · Old vs new

เทียบสองสูตรตรง ๆ:

เดิม · tmux-basedใหม่ · codex exec headless
Engineomx ผ่าน tmux windowcodex exec -m gpt-5.5 headless
Isolationmaw wake --wtgit worktree add (manual)
API keysharedCODEX_HOME per coder (~/.codex-team/N/)
Dispatchmaw hey session:memberprompt ใส่ตรงใน codex exec
Monitoringmaw peekgit -C agents/coder-N log
Callbackmaw hey กลับ leadmaw hey กลับ lead (เหมือนกัน)

5 จุดที่ใหม่จริง ๆ · The five genuinely new points:

  1. CODEX_HOME isolation — แยก API key per coder กัน rate-limit ชนกัน · separate API key per coder to avoid rate-limit collisions.
  2. codex exec headless — ไม่ต้อง tmux, ไม่ต้อง maw wake, รันตรงจาก shell · runs straight from the shell.
  3. -m gpt-5.5 ไม่ใช่ -c model= — trap ที่เจอจริง · a real trap.
  4. cargo clippy -- -D warnings ต้องใส่ใน prompt เสมอ ไม่งั้น coder commit code ที่มี warning · always put it in the prompt or coders commit warnings.
  5. cd เข้า worktree ก่อนcodex exec ใช้ pwd · codex exec uses pwd, so cd into the worktree first.

นี่คือ lightweight version: ไม่ต้อง charter YAML, ไม่ต้อง maw team up — แค่ worktree + codex exec + maw hey callback. · The lightweight version: no charter YAML, no maw team up — just a worktree, codex exec, and a maw hey callback.

Dual-Layer Codex Fleet — 10 coders ขนาน · The dual-layer fleet

Evolution ขั้นสุด: รวม headless + tmux เป็น 10 coders ขนาน (5 + 5) แยก orchestration/execution layer ชัด.

The final evolution: combine headless + tmux into 10 parallel coders (5 + 5), cleanly splitting the orchestration and execution layers.

Layer 1 — Headless (×5)
  Agent(run_in_background) → codex exec → git worktree
  ✅ harness tracked   ✅ fire-and-forget   ❌ รับ maw hey กลับไม่ได้

Layer 2 — Tmux (×5)
  maw team up → tmux panes → maw hey dispatch
  ✅ ส่ง/รับ maw hey ได้   ✅ peer coordination   ❌ ต้อง maw peek loop

เลือก layer ตามงาน: fire-and-forget งานเดี่ยว ๆ → headless; งานที่ต้อง peer-coordination หรือสั่งกลับระหว่างทาง → tmux.

Pick the layer by task: fire-and-forget single-shot work → headless; anything needing peer coordination or mid-flight redirection → tmux.

Traps ของ dual-layer · The dual-layer traps

  1. headless รับ maw hey กลับไม่ได้ — ไม่มี tmux pane; ใช้ tmux layer สำหรับ peer-coordination เท่านั้น. คนพลาดง่ายสุด.
  2. CODEX_HOME trust per repo — ต้อง pre-trust ใน config.toml ไม่งั้น codex ถามตอน exec (ดู Trust Loop ด้านล่าง).
  3. headless: ใน YAML ทำ maw parser พัง — ต้อง comment out หรือแยกไฟล์.
  4. maw team down --only ฆ่าหมดทุกตัว — trap! ใช้ maw tmux kill ต่อ window แทน.
  5. 15 processes จาก 5 coders เป็นเรื่องปกติ — 5 × 3 child processes.

The five traps: (1) headless cannot RECEIVE maw hey — no tmux pane; use the tmux layer for peer coordination only (the easiest miss). (2) CODEX_HOME needs per-repo trust in config.toml or codex prompts at exec time (see Trust Loop below). (3) headless: in YAML breaks the maw parser — comment it out or split the file. (4) maw team down --only kills ALL — use maw tmux kill per window instead. (5) 15 processes from 5 coders is normal (5 × 3 child processes).

Trust Loop + BunInvokeRuntime · Two supporting tricks

Trust Loop — วนเขียน trust_level = "trusted" ลงทุก CODEX_HOME และ generic ~/.codex/config.toml เพื่อตัด interactive prompt ตอน agent เริ่มงานย่อยในซับโฟลเดอร์.

Trust Loop — loop trust_level = "trusted" into every CODEX_HOME and the generic ~/.codex/config.toml to kill the interactive prompt when an agent starts subfolder work.

BunInvokeRuntime — migration trick ที่ทำให้ thin Rust CLI รัน plugin เดิมได้หมดทันที:

invoke_ts() stub → BunInvokeRuntime
   = bun run <entry_path> -- <args>
   = 113 plugins work immediately, 0 rewrites

Thin Rust CLI → bun bridge — 113 plugins ใช้ได้ทันทีไม่ต้อง rewrite. เป็น migration path ที่ fleet มองว่าทองสุด.

A thin Rust CLI → bun bridge: all 113 plugins run immediately with zero rewrites — the migration path the fleet rated highest.

Checklist

  1. งาน fire-and-forget → headless (dispatch); งานที่ต้อง coordinate → tmux (up).
  2. ทุก coder ต้องมี worktree ของตัวเอง — codex exec ไม่มี worktree = งานหาย.
  3. แยก CODEX_HOME per coder กัน rate-limit ชนกัน; pre-trust trust_level = "trusted" กัน prompt.
  4. ใช้ -m gpt-5.5 (ไม่ใช่ -c model=) และใส่ cargo clippy -- -D warnings ใน prompt.
  5. ใช้ Agent(run_in_background=true) — ไม่ใช่ Shell & (harness มองไม่เห็น).
  6. อย่าใช้ maw team down --only (ฆ่าหมด) — maw tmux kill ต่อ window.
  7. headless รับ maw hey ไม่ได้ — lead สั่ง headless ผ่าน prompt ตอน dispatch เท่านั้น.