Repository navigation
Leave late input to Codex's adapter at Stop only where it starts turns over App Server - #3435
Merged
Merged
Conversation
…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
reviewed
Oct 21, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
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.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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]>
leaf-agent
approved these changes
Oct 21, 2026
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]>
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.
#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_deliverytool output. On thecodex queueroute (the desktop app and IDE), the adapter queues aleaf-deliverypointer, which Codex records as auserMessageand 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_inputis true only for an App Server adapter. It reads the live adapter's lease record (codex_adapter.running_adapter, formerly_running_adapter), whoseapp_servernames the transport, under the adapter start lock: an adapter takes its lease before writing that record, andpreparing_adapterholds 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.jsoncarries 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 baseHarness.later_turn_takes_inputdocstring now states the criterion: the later turn must open without the agent asking and show the user less than continuing the ending turn would.codex.pyandhook_transport.pyheaders,session-lifetime.md,harness-codex.md("Delivery"), the site's "Stop hook checks" andTODO.mdnow 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 auserMessageitem holdingM, and each answered._item_delivery_idalready reads a queuedleaf-deliverypointer as auserMessage. 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_turnruns 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_addressreturns to its queue form: the new owner's redelivered update comes through Stop.interact_support.adapter_lease), as a running adapter does.adapter_is_live, the queue case and two reminder cases fail; with it always false, the App Server case fails.codex-queuejourney'sresumestep again requires the comment to enter the empty-input resumed turn and start no turn of its own;codex-app-serverkeeps Leave late input to Codex's adapter at Stop, as a watch takes it #3425's requirement. Both journeys pass on this branch. In thecodex-queuerun, the four deliveries offered while the task was idle each arrived as aleaf-deliveryuser message, and the comment sent during the resumed turn arrived through Stop with no message of its own.