Files
superpowers/skills/using-superpowers/references/codex-tools.md
Drew Ritter c97988d8d1 feat(codex): SDD dispatch routing, fork hygiene, and final-review wave termination
Codex SDD runs at frontier tiers spin out: subagents inherit the
session's model and effort, review seats find real-but-endless defects
every round, and the final whole-branch review has no reachable
termination state. Field forensics across multiple real sessions traced
the mechanism: spawn_agent's fork_turns defaults to "all" (full-context
forks that also refuse model overrides), omitted model/effort params
inherit the frontier parent, and dispatch rules loaded at session start
do not survive context compaction — a compacted controller reverts to
inheritance exactly when the session is longest and most expensive.

Three coordinated changes:
- codex-tools.md: every SDD spawn sets fork_turns "none" plus explicit
  model/reasoning_effort when the schema supports them (Codex 0.145+),
  with an inheritance warning for older builds; reviewer tier never
  exceeds implementer tier and fix rounds never get effort bumps.
- task-brief/review-package print a dispatch tuple with their output
  (review-package grows --role for re-review/final-review), putting the
  routing values in front of the controller at the moment of dispatch —
  reprinted every round, so they survive compaction by construction.
- SKILL.md: the final-review wave closing is policy, not a verdict —
  one fix dispatch, one scoped re-review, residuals adjudicated to the
  ledger; one-off review procedures never become standing; Model
  Selection defers to platform role tables where one exists.

Validated live: a previously spun-out 14-task run (8h, 6 tasks, died
mid-loop) re-executed to completion under these changes — bounded fix
loops, single-cycle final review, ~20 consecutive correctly-routed
dispatches across two compactions. Reviewer-tier matrix (125 cells)
showed no calibration cost: clean-diff approvals and planted-defect
recall are identical across tiers. Eval scenarios to follow before any
upstream submission.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 22:57:28 -07:00

83 lines
4.2 KiB
Markdown

## Subagent dispatch requires multi-agent support
Add to your Codex config (`~/.codex/config.toml`):
```toml
[features]
multi_agent = true
```
This enables `spawn_agent`, `wait_agent`, and `close_agent` for skills like `dispatching-parallel-agents` and `subagent-driven-development`. When using subagent-driven-development, close reviewer subagents when their review returns. Keep each implementer subagent open until its task's review passes — the fix loop resumes the implementer — then close it. If your harness cannot send another message to a spawned agent, dispatch each fix round as a fresh implementer carrying the brief, the report file, and the findings.
## SDD dispatch: pin fork_turns and the model on every spawn
Every `spawn_agent` call in subagent-driven-development sets
`fork_turns: "none"`. The parameter defaults to `"all"`, which forks your
entire session transcript into the child — the opposite of the fresh,
constructed context SDD requires — and a full-history fork also refuses
model and effort overrides. Never omit the parameter, and never pass
`"all"` or a turn count for an SDD dispatch.
Before Task 1, check your `spawn_agent` tool schema for `model` and
`reasoning_effort` parameters (present on Codex 0.145+).
**If the parameters exist**, set both explicitly on every dispatch. The
task-brief and review-package scripts print the exact values for each
dispatch as a `dispatch (codex spawn_agent):` line with their output —
copy that line's values onto the spawn_agent call verbatim, every time,
even late in a long session. The mapping they print: every SDD seat runs
`gpt-5.6-terra` — implementers and reviewers at `reasoning_effort: high`,
scoped re-reviews at `medium`. On Codex this mapping IS the Model
Selection section — including the final review, which stays on
terra/high rather than "most capable available." Never give a subagent
your session's model when you run a frontier config (sol at xhigh or
max): reviewer tier never exceeds implementer tier, and a fix round
never gets an effort bump. Rounds 4-5's "more capable model" means a
fresh implementer at the same tier; a task that genuinely needs more
than terra/high is a BLOCKED escalation to your human partner, not a
quiet tier climb. Inherited frontier-tier subagents are a measured cause
of SDD runs spinning out for hours: review seats that inherit a frontier
model at maximum effort find real-but-endless defects every round, and
fix diffs balloon instead of converging.
The model names here track Codex's `spawn_agent` allowlist (currently
`gpt-5.6-sol` and `gpt-5.6-terra`). When the allowlist changes, update
this file and the hint lines in task-brief and review-package together.
**If the parameters do not exist** (Codex 0.144 and earlier), every child
inherits your session's model and effort and no override is possible —
role files in `~/.codex/agents/` do not attach to spawns either. Say so
to your human partner before starting a plan of more than a few tasks,
and offer the choice: proceed with inheritance, or restart the session
at a lower effort so the whole run — controller and children — pays the
lower rate.
## Environment Detection
Skills that create worktrees or finish branches should detect their
environment with read-only git commands before proceeding:
```bash
GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
BRANCH=$(git branch --show-current)
```
- `GIT_DIR != GIT_COMMON` → already in a linked worktree (skip creation)
- `BRANCH` empty → detached HEAD (cannot branch/push/PR from sandbox)
See `using-git-worktrees` Step 0 and `finishing-a-development-branch`
Step 1 for how each skill uses these signals.
## Codex App Finishing
When the sandbox blocks branch/push operations (detached HEAD in an
externally managed worktree), the agent commits all work and informs
the user to use the App's native controls:
- **"Create branch"** — names the branch, then commit/push/PR via App UI
- **"Hand off to local"** — transfers work to the user's local checkout
The agent can still run tests, stage files, and output suggested branch
names, commit messages, and PR descriptions for the user to copy.