Write-review team: agents scheduled by code¶
A small team of coding agents that reviews its own work: one writer implements a change request, one reviewer per check of a checklist reviews the change, and a director decides when to review, when to send the change back and when to stop.
The director is a program, not a model. The model only writes content: the change and the reviews. The agents and the director talk through actor mailboxes.
The code, the prompts, the checklist and a public task are in
examples/agent/write_review.
It runs with any model the Codex CLI can reach.
One round¶
- The director creates a mailbox for the writer and one per check, with fixed identities, and hosts them in its own process.
- It mails the task to the writer and starts one
codex execsession for it. The session reads the letter through a mailbox MCP server that is added to Codex for this call only. - The writer's reply is only the signal that the round is done. The change under review
is
git diff HEADof the writer's working tree, exported by code: a model may describe a change it never made, and a reviewer cannot tell that from a real one. - The director mails the same change to every reviewer, verbatim, and starts one session per reviewer, in a read-only sandbox.
- All
CLEAN: the run ends. AnyNEEDS_FIX: the director sends every review back to the writer, verbatim and labelled, and the next round begins. At mostmax_rounds.
Every wait is a bounded wait on something that happens: a reply in a mailbox, the end of a session, a timeout. Nothing polls a model and nothing can deadlock. No review starts before a real change exists; no send-back goes out before every reviewer has answered, ended or timed out; every session is stopped before the run returns.
Workers and mailboxes¶
A Codex session is not woken by a letter, so the director starts a session per letter: reviewers are fresh every round, and the writer gets a new session for a send-back, with its earlier change in the working tree. The mailbox tools are set to run without an approval prompt, because nobody can answer one in a one-shot session. The address of a worker never changes, so a thread of letters is the whole run, and the mailboxes' event log reads back as one document with the mailbox replay tool.
Resuming a killed run¶
The director writes a checkpoint (state.json) at every phase change and sends every
letter with a deterministic idempotency key; with mailbox_state_dir the mailboxes journal
their state. python -m write_review run --resume <run> therefore continues a run that was
killed: the mailboxes come back with their letters, states, leases, claim tokens and
idempotency keys, the phase is read from the checkpoint, and a re-sent letter returns the
one that already exists instead of a copy. A letter a dead worker had claimed keeps its
lease, so the resumed run sends the successor of that letter and completes the round; the
superseded letter remains as the record of that attempt.
It covers a process restart, not a power loss, and not a tool side effect twice. On a
pulsing build without mailbox_state_dir, the mailboxes stay in memory and --resume
refuses to start.
The model¶
The director never calls a model. Every worker is a codex exec session: model in
team.toml is passed as codex -m, and where the model is served is Codex's own
setting, so any provider Codex can talk to works.
What it does not promise¶
That the change is correct, that the reviews are right, or that a side effect happens exactly once. One run is one run, not a success rate. A session runs in Codex's sandbox, which lets it read the rest of the machine: the writer is told to stay inside the repository, but nothing stops a model from looking further. Without a mailbox state directory the mailboxes are in memory only, with everything that follows from it.
Where the home-page replay comes from¶
The replay on the project's home page was recorded on 2026-12-02 with an earlier,
internal version of the director: the same rounds and the same eight checks, with workers
that a letter could wake. The model was deepseek-v4.1-flash, served from an internal
endpoint, and the task was a private one.
The open version ran twice on the public task on 2026-12-03, with the same model and the
Codex build this project was tested with: clean in one round both times, acceptance
tests 7/7, in 256 s and 387 s. Two runs are two runs, not a success rate.