Skip to content

Leave late input to Codex's adapter at Stop, as a watch takes it - #3425

Merged
max-sixty merged 2 commits into
mainfrom
agent-afa2c39fc2a6fece6
Oct 21, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-afa2c39fc2a6fece6

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Applies #3256's Stop rule to Codex. #3256 made Claude Code's and Pi's Stop hook hand no late page input into a finishing turn where a watch follows it, so the turn ends on its answer and the input gets a turn of its own. Codex's Stop hook still blocked the turn's end and handed a late comment in, so the agent wrote one more message after its answer, and that reply became the turn's final message.

What changes

  • One predicate says whether a later turn takes late input (Harness.later_turn_takes_input). It is the watch between turns for Claude Code and Pi (watches_between_turns), and the live delivery adapter for Codex (adapter_is_live). hook_transport.carry_turn and CodexHarness.offer_at_step both read it, so Codex's Stop offers nothing while the adapter runs. The turn closes, and the adapter offers the input in a turn of its own: a turn/start with a leaf_delivery tool output over App Server, or the queue's next turn through codex queue. A Codex task that waits with leaf wait has no adapter, so its Stop still hands input over, as under plain claude -p.
  • An owed update this owner holds no usable reference for counts as input, not as a debt (hook_transport.read_plans). Such an update, received by another session before the page changed hands, is already deliverable again (delivery.unreferenced). Stop used to remind the agent about it as well, which with Codex's adapter running continued the turn with a reminder naming the leaf wait that would deliver its reference. Now Stop hands it over with the other input or leaves it to the later turn. The same applies to Claude Code and Pi with a watch.
  • Prose in the codex.py and hook_transport.py headers, session-lifetime.md, harness-codex.md ("Delivery"), the site's "Stop hook checks" and TODO.md now says Stop hands input over only where nothing opens a later turn for it.

Codex's TUI shows every message of a turn

The question was whether replacing the final message matters in Codex the way it does in Claude Code's focus view. In codex-cli 0.160.0's TUI, a turn asked to send a progress message, run a command and then answer showed all three in the transcript (• ALPHAONE, • Ran echo hi, • OMEGATWO). So the TUI never hid the answer. What this change keeps in Codex is that a turn's final message is its answer, and that late input gets a turn of its own; surfaces that show a turn's final message alone were not checked.

Tests

  • New test_a_codex_stop_leaves_late_input_to_the_adapters_own_turn: with the adapter live, a comment collected as the turn ends gets no Stop output, the turn closes, and the adapter queues it once. It fails with the Stop early return removed (Stop blocks with the envelope).
  • test_a_stop_reminder_recovers_the_exact_reply_address: the handoff cases now reach the new owner through the adapter's offer after Stop. They fail without the read_plans change (Stop continues with the reminder).
  • test_codex_stop_leaves_quiet_input_but_delivers_the_whole_batch_with_owed_input is deleted: it asserted that an owed comment keeps the turn open with the adapter running, the behavior this PR reverses. test_a_codex_stop_keeps_the_revision_returned_by_its_offer now runs without an adapter, where Stop still offers.
  • The codex-app-server and codex-queue journeys pass. Their resume step now runs on both transports and requires that a comment sent during an empty-input resumed turn, whose first boundary is its Stop, is answered in a turn of its own rather than handed into the resumed turn.
  • Focused suites pass, except test_codex_app_server.py::test_a_turn_that_shares_a_user_message_leaves_the_delivery_owed, which fails the same way on main (KeyError: 'status.json', from Refuse a Codex delivery turn's answer when a user message shares the turn #3380 meeting Move the cursor and status into the log, fold small records, and retire state-home records by their pages #3384).

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 2 commits October 20, 2026 21:56
Codex's Stop hook handed a comment that arrived as the turn ended into that turn, so the agent wrote one more message after its answer. `Harness.later_turn_takes_input` now says whether something opens a later turn for such input: the watch between turns on Claude Code and Pi, the live delivery adapter on Codex. While the adapter runs, Codex's Stop offers nothing; the turn closes and the adapter offers the input in a turn of its own. A Codex task without an adapter, as one that waits with `leaf wait`, still has Stop hand input over.

An owed update this owner holds no usable reference for, already deliverable again, no longer also counts as a Stop reminder: Stop hands it over or leaves it to the later turn, instead of continuing the turn with a reminder naming the `leaf wait` that would deliver it.

Behavior changes in tests: the Codex Stop-handover tests that ran with an adapter now expect the adapter's own turn, and the codex journeys' `resume` step, now on both transports, requires the comment be answered in a turn of its own.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 0a4fdb8 into main Oct 21, 2026
2 of 3 checks passed
@max-sixty
max-sixty deleted the agent-afa2c39fc2a6fece6 branch October 21, 2026 05:11
max-sixty added a commit that referenced this pull request Oct 21, 2026
…s over App Server (#3435)

#3425 applied #3256's Stop rule to Codex: while the delivery adapter
runs, Stop hands no late input into the finishing turn, and the adapter
offers it in a turn of its own. Over App Server that turn opens quietly,
on a `leaf_delivery` tool output. On the `codex queue` route (the
desktop app and IDE), the adapter queues a `leaf-delivery` pointer,
which Codex records as a `userMessage` and runs as a user turn of its
own (measured below), so #3425 turned every comment that lands at Stop
into a message in the user's name. Before #3425 such a comment entered
the finishing turn instead. Max's rule: "In codex, adding a message to
the user turn is very noisy to the user, so we only want to do it when
we need to."

### What changes

- **`CodexHarness.later_turn_takes_input` is true only for an App Server
adapter.** It reads the live adapter's lease record
(`codex_adapter.running_adapter`, formerly `_running_adapter`), whose
`app_server` names the transport, under the adapter start lock: an
adapter takes its lease before writing that record, and
`preparing_adapter` holds the start lock until the adapter has written
it, so Stop never reads a half-started adapter's empty record. Stop
reads it only in a session that holds a page and has a live adapter, so
a hook in a session holding nothing still loads no page reading.
`build/browser/protocol-baseline.json` carries the record's renamed
reference. On the queue route Stop again hands late input into the
finishing turn, as before #3425. The base
`Harness.later_turn_takes_input` docstring now states the criterion: the
later turn must open without the agent asking and show the user less
than continuing the ending turn would.
- Prose in the `codex.py` and `hook_transport.py` headers,
`session-lifetime.md`, `harness-codex.md` ("Delivery"), the site's "Stop
hook checks" and `TODO.md` now names the App Server adapter, not any
adapter.

### Evidence (codex-cli 0.160.0)

`codex queue --thread T --message M`, run twice while a turn ran,
produced two later turns, each opening on a `userMessage` item holding
`M`, and each answered. `_item_delivery_id` already reads a queued
`leaf-delivery` pointer as a `userMessage`. How the desktop app and the
TUI draw that item was not checked.

### Tests

-
`test_a_codex_stop_leaves_late_input_to_an_app_server_adapters_own_turn`
runs both transports: with an App Server adapter Stop prints nothing and
leaves the comment collected for the adapter; with a queue adapter Stop
blocks with the envelope, the comment opens in the ending turn, and
nothing is queued.
- `test_a_stop_reminder_recovers_the_exact_reply_address` returns to its
queue form: the new owner's redelivered update comes through Stop.
- Tests that took a bare adapter lease now write its record
(`interact_support.adapter_lease`), as a running adapter does.
- Controls: with the predicate back at `adapter_is_live`, the queue case
and two reminder cases fail; with it always false, the App Server case
fails.
- The `codex-queue` journey's `resume` step again requires the comment
to enter the empty-input resumed turn and start no turn of its own;
`codex-app-server` keeps #3425's requirement. Both journeys pass on this
branch. In the `codex-queue` run, the four deliveries offered while the
task was idle each arrived as a `leaf-delivery` user message, and the
comment sent during the resumed turn arrived through Stop with no
message of its own.

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants