Skip to content

Leave late input to Codex's adapter at Stop only where it starts turns over App Server - #3435

Merged
max-sixty merged 4 commits into
mainfrom
codex-stop-quiet-route
Oct 21, 2026
Merged

max-sixty merged 4 commits into
mainfrom
codex-stop-quiet-route

Conversation

@max-sixty

@max-sixty max-sixty commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

#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 Leave late input to Codex's adapter at Stop, as a watch takes it #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 Leave late input to Codex's adapter at Stop, as a watch takes it #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

max-sixty and others added 2 commits October 20, 2026 22:55
…s over App Server

#3425 had Codex's Stop hand no late input into the finishing turn while
any delivery adapter ran. On the `codex queue` route the adapter then
queues a `leaf-delivery` pointer, which Codex records as a user message
and runs as a user turn, so a comment arriving at Stop became a message
in the user's name. `CodexHarness.later_turn_takes_input` now reads the
live adapter's lease record (`codex_adapter.running_adapter`) under the
start lock and is true only for an App Server adapter; on the queue
route Stop again hands late input into the finishing turn.

Behavior changes protected by tests: with a queue adapter, Stop blocks
with the envelope and the comment opens in the ending turn; with an App
Server adapter, Stop leaves it collected for the adapter. The
`codex-queue` journey's resume step again requires the comment to enter
the resumed turn.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	docs/how-it-works.html

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pnpm run check:browser fails because the codex-adapter schema description now names running_adapter, while the committed build/browser/protocol-baseline.json still names _running_adapter. Regenerating with pnpm run build:browser changes only that baseline line; please include it so the test job can proceed. The same check passes on current main.

I can push the generated update if you prefer.

leaf-agent
leaf-agent previously approved these changes Oct 21, 2026
A Stop hook in a session holding no page imported the adapter module,
and with it page reading, to read a transport it never used.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 95ad0d0 into main Oct 21, 2026
3 checks passed
@max-sixty
max-sixty deleted the codex-stop-quiet-route branch October 21, 2026 06:27
leaf-agent added a commit that referenced this pull request Oct 22, 2026
Both Codex adapter variants in [nightly CI run
39766486203](https://github.com/max-sixty/leaf/actions/runs/39766486203)
leave a Stop call blocked on an acknowledged but unanswered comment,
then expect later comments to start queued deliveries. The adapter
correctly keeps collecting while that turn is still active, as the
[queue Stop rule in #3435](#3435)
requires. The journey now answers the first comment and lets Stop close
that turn before testing later deliveries on the same adapter. It uses
the current response address when posting each answer.

Both variants failed before this change and pass afterward. The model
checks for a blocked unanswered Stop and for late input on the two Codex
transports also pass. The adapter itself is unchanged.

---------

Co-authored-by: leaf-agent <[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