Repository navigation
Leave late input to Codex's adapter at Stop, as a watch takes it - #3425
Merged
Merged
Conversation
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]>
leaf-agent
approved these changes
Oct 21, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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_turnandCodexHarness.offer_at_stepboth 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: aturn/startwith aleaf_deliverytool output over App Server, or the queue's next turn throughcodex queue. A Codex task that waits withleaf waithas no adapter, so its Stop still hands input over, as under plainclaude -p.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 theleaf waitthat 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.codex.pyandhook_transport.pyheaders,session-lifetime.md,harness-codex.md("Delivery"), the site's "Stop hook checks" andTODO.mdnow 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
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 theread_planschange (Stop continues with the reminder).test_codex_stop_leaves_quiet_input_but_delivers_the_whole_batch_with_owed_inputis 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_offernow runs without an adapter, where Stop still offers.codex-app-serverandcodex-queuejourneys pass. Theirresumestep 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.test_codex_app_server.py::test_a_turn_that_shares_a_user_message_leaves_the_delivery_owed, which fails the same way onmain(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).