Running a child on Codex

Bellwether starts a child on Codex when agent_spawn receives kind: "codex". The build and its checks target Codex 0.160.0.

A codex child can report to its parent (parent_report), ask to retire (request_retirement) and ask for more depth (agent_request_depth). Codex's approval policy refuses every other Bellwether tool, so a codex child can't start children or message another agent. Bellwether doesn't send keystrokes to a Codex dialog.

Launch arguments

Bellwether asks herdr to start Codex with these arguments:

codex -a never -s workspace-write \
  -c 'projects={"<cwd>"={trust_level="trusted"}}' \
  -c 'mcp_servers.bellwether={command="<node>",args=[…,"--child","<child id>"],env_vars=[…],tools={parent_report={approval_mode="approve"},request_retirement={approval_mode="approve"},agent_request_depth={approval_mode="approve"}}}' \
  'Your task is in ~/.bellwether/prompts/<child id>.md. Read it, then do what it says.'

herdr types the line into a shell and cuts any command at 1,024 bytes. When the line would pass that cap, the spawn fails before herdr starts Codex. That error reports the length.

Each tab sets CODEX_HOME to match the daemon. The daemon uses ~/.codex unless its own environment names another home. The child and the daemon then read the same sessions.

Finding the session

herdr detects Codex but doesn't report a session for it. herdr 0.9.5 lists a codex integration that would install a SessionStart hook, and without that hook herdr has no session to report. So Bellwether finds the session in Codex's own files. Codex writes one rollout per session, at $CODEX_HOME/sessions/<year>/<month>/<day>/rollout-<local time>-<session id>.jsonl. The first line gives the session's id, working directory and start time. Each message follows on a line of its own.

Codex writes the rollout once the first prompt is in. For up to 30 seconds, the spawn waits for a rollout that

The sentence points at the brief file, whose name is the child id, so only one session can match. The child record keeps the session id, the Codex home as store, and the rollout as transcript. Without a match, the spawn fails. Its error gives the sessions directory and what the last look found. The spawn closes the tab and keeps the brief file for inspection.

agent_read returns the last assistant message in the rollout. The watcher reads the same message for an idle event, and it counts a growing rollout as activity.

Dialogs

Codex holds a pending approval in memory, not in the rollout. So Bellwether reads a dialog off the screen, where Codex marks the selected option with ›.

Codex shows "Hooks need review" on the first start after ~/.codex/hooks.json changes. Trusting a hook lets it run outside the sandbox, so Bellwether never answers that dialog, and no keystroke does either. The spawn fails and names the dialog. To continue, run codex once in a terminal, review the hooks, and spawn again. herdr can show the pane as idle while that dialog waits, so the spawn also checks the screen when the rollout never appears.

Resume and refusals

agent_spawn with resume and agent_restart reopen a codex child with codex … resume <session id>, under the same child id. The session keeps its rollout.

The spawn refuses each of these before it opens a tab:

agent_move doesn't cover codex children.