Repository navigation
Start page input's turn in an open Codex desktop chat, with no message in the user's name - #5424
Merged
Merged
Conversation
…e in the user's name A page comment to an idle desktop chat arrived as a queued `<leaf-delivery>` user message. The app's chats run on an App Server child over stdio that nothing else can reach, and the local daemon holds none of them, but the router the app's own clients share can ask a chat's owner to start a turn. The adapter now does that first in a desktop chat, with the delivery as a `leaf_delivery` tool output, and falls back to `codex queue` and the wake on no owner or any failure. Run on app 26.1029.61003, on a second instance with its own home: a page comment through a real adapter opened a turn whose stored items start on the tool output with no user message, and the window drew only the answer. An unowned chat on the same code still took the queue, whose turn opens on the `<leaf-delivery>` user message. `notes/codex-integration.md` records each route's runs and how to repeat them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
reviewed
Nov 5, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The desktop start adopts its turn without the epoch check the App Server start applies (inline).
…unclear one from the chat's transcript The desktop route queued its input whenever it couldn't read the router's answer, so a start the app had taken ran a second time from the queue. That included a `success` of another shape and the owner's own five-second `thread-follower-start-turn-timeout`, after which its start runs on. A crash between the app's answer and the acceptance sent the start again. The start now keeps the App Server delivery contract (`codex.start_app_server_delivery`). Leaf reserves it as a `StartingOffer` once the app names the chat's owner. Only the refusals made before the owner runs the request release it to the queue: `no-client-found`, `no-handler-for-request` and `request-version-mismatch`. Any other answer leaves it reserved. The chat's transcript settles it, since the app records the turn's `leaf_delivery` tool output there with the delivery id and turn id (`codex.transcript_delivery_turn`). Leaf accepts the delivery in that turn, or, once no turn is running and 60 s have passed without one, abandons it as unconfirmed without sending it again. Router frames that aren't JSON objects, and answers whose fields moved, now fall back before the start, or stay uncertain after it, instead of escaping as `AttributeError` and stranding the input. The adapter's log gives the reason for every fallback to the queue, a discovery version the app doesn't know included, which reads as `no-client-found`. The desktop tests assert each request's method, version, clients and params, and cover each fallback, each uncertain answer, abandonment held back while a turn runs, and a crash after the app's answer. Each of 16 source mutations fails them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
reviewed
Nov 5, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
Settling an unconfirmed start depends on a transcript record shape nothing here shows the app writing (inline).
… outside the app An unclear desktop start stood forever, holding back every later comment, when the session record still showed a turn a crash left open: settling read the record's raw `turn_open`. It now reads `codex_state.delivery_turn`, the dated reading the queue's gate uses, which ages such a turn out, so the start is abandoned as unconfirmed once the settle window passes. Settling also ran only in an adapter that saw the app's originator, so one a terminal resume started raised `AppServerDeliveryUncertain` on every pass. Any adapter of the chat now settles it. New tests fail before: settling from the transcript after the adapter loses the app's environment, and abandonment with a turn left open an hour ago. Two mutations that survived now fail the tests: settling on another delivery's tool output, and leaving a refused start reserved after the queue command fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
max-sixty
marked this pull request as ready for review
November 5, 2026 18:15
… write the tests' records in its shape `codex.transcript_delivery_turn` settles a desktop start whose answer Leaf couldn't read by finding an `event_msg` `item_completed` record whose item is a `FunctionCallOutput` named `leaf_delivery`. `notes/codex-integration.md` now holds that record as the app's bundled Codex 0.166.0-alpha.6 (app 26.1029.61003) wrote it on 5 November 2026, with how to capture it again. Every field the reader uses matched the record, so the reader is unchanged; its docstring now says which fields a tool output's item holds and that the early stop relies on Codex writing records in timestamp order. The desktop tests' transcript now stamps records as Codex does, in UTC with a `Z` and an ordinal. One helper writes the tool output record with the captured fields, in place of three hand-built copies that left out its `id`, `thread_id` and times. No assertion changed. Through the same binary in a scratch home, Leaf envelopes of 55 bytes, 60 KB and 400 KB were stored verbatim, and the reader returned the turn `turn/start` had answered each time.
leaf-agent
approved these changes
Nov 5, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 5, 2026
`test_a_wait_takes_the_suites_deadline` has failed on `main` since #5424, which bounded the Codex desktop router's server thread in `tests/model/test_codex_adapter.py` with `server.join(timeout=10)`. It now takes `STATED_TIMEOUT`, as every Python-side wait does (`tests/AGENTS.md`, "Waits"). The deadline check and `tests/model/test_codex_adapter.py` pass (80 tests). > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5.5 <[email protected]>
leaf-agent
added a commit
that referenced
this pull request
Nov 7, 2026
…t_dir fixture (#5684) #5424 added two `tempfile.TemporaryDirectory(dir="/tmp")` calls to `tests/model/test_codex_adapter.py`, one in `desktop_router` and one in `test_a_desktop_chat_the_app_cannot_start_falls_back_to_the_queue`. The nightly `test_the_resources_a_fixture_owns_are_taken_from_that_fixture` journey refuses these calls, because the `socket_dir` fixture owns short directories that hold sockets. `desktop_router` now takes its home directory from the caller, and each test that uses it asks for `socket_dir`. Nothing outside the tests changes. The journey fails on main `02a1e05cb` and passes on this branch (`uv run pytest --run-nightly tests/journeys/test_interact_layer.py::test_the_resources_a_fixture_owns_are_taken_from_that_fixture`). The desktop tests in `test_codex_adapter.py` can't bind an `AF_UNIX` socket in this sandbox (`Errno 97`), on main and on the branch alike, so this PR's CI is the first run of them on the new code. Refs #5658 — automated triage. It fixes one of that issue's twelve cases. 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.
A page comment to an idle Codex desktop chat arrived as a queued
<leaf-delivery>user message, which the chat drew as if the user had typed it. A chat a window of the app has opened now takes the delivery as a turn the app starts, with the complete envelope as aleaf_deliverytool output. The chat shows the agent's answer and nothing for the input. A chat with no owner, such as one not opened since the app launched, stays oncodex queueand the wake.Closes #4015
The route
The app's chats run on an App Server child it speaks to over stdio, so nothing else can connect to that server. The local daemon and
codex app-server proxydon't reach those chats. What does is the router the app's own clients share at$CODEX_HOME/ipc/ipc.sock: a client asksthread-owner-discoverywhich client owns a chat, then sends that ownerthread-follower-start-turn, and the owner callsturn/starton its own App Server with the chat's settings.src/leaf/codex_desktop.pyis that client, and it sends the request every Leaf delivery turn already takes (codex.app_server_turn_start_params).The adapter tries this first in a desktop chat. The start keeps the App Server delivery contract (
codex.start_app_server_delivery), so the same input never runs twice:StartingOffer) once the app has named the owner. Only a refusal made before the owner ran the request releases it to the queue:no-client-found,no-handler-for-requestandrequest-version-mismatch.successof another shape, the owner's own 5 sthread-follower-start-turn-timeout, or an unreadable frame. The start then stays reserved. The chat's transcript settles it, since the app records the turn'sleaf_deliverytool output there with the delivery id andturn_id(codex.transcript_delivery_turn). Leaf accepts it in that turn. If the page reads no turn of the chat as running and 60 s have passed without it, Leaf abandons it as unconfirmed (codex.abandon_uncertain_delivery), and the page says so. That reading iscodex_state.delivery_turn's, whose dated activity ages out a turn a crash left open. It is never sent again. A crash between the app's answer and the acceptance leaves the same reservation, settled the same way. Any adapter of the chat settles it, one a terminal resume started outside the app included.Opened, so the page reads a pickup in that turn at once.The envelope is the queue's, whose replies the agent writes with
leaf thread reply, because Leaf sees nothing of the turn but its id.Evidence
Everything below ran on app 26.1029.61003 (bundled Codex 0.166.0-alpha.6). Turns ran only on threads this work created, on a second instance of the app with its own
CODEX_HOMEand user data, or in that instance's own router.openreaches the default handler. Its stored turn opens onuserMessage: <leaf-delivery id="2dbbf7ed" operation="delivery read" />.functionCallOutput name=leaf_deliverywith nouserMessage, the page log holdspickup phase=openedwith that turn's id, and the agent's reply reached the page at 28.5 s on a busy machine. The adapter log stayed empty.thread_unload_delay_secs = 0. After an app restart the chat had none. On the running app, read-only discovery found one owned chat among those listed, the one in use, answered in about a millisecond. A scratch chat resumed only by the wake had none after more than two minutes.thread/listthrough it lists every chat asnotLoaded, the chat in use included, andthread/loaded/listis empty. On a scratch chat the app held,thread/resumewas refused withalready has an active writerandturn/startwiththread not found. WithCODEX_APP_SERVER_USE_LOCAL_DAEMON=1and a daemon answering, the app still started its stdio child.notes/codex-integration.mdrecords these runs and how to repeat them.uv run pytest tests/model/test_codex_adapter.py tests/model/test_codex_app_server.py tests/model/test_session_lifecycle.py -n2passes (205). The desktop tests drive a fake router that speaks the observed framing, and assert each request's method, version, source and target client, and params. They cover each definitive fallback with its logged reason, each uncertain answer settled from a transcript and not by another delivery's tool output, settlement in an adapter started outside the app, abandonment held back while a turn runs but not by one a crash left open, a refused start that the queue then fails, and a crash after the app's answer. Each of 18 source mutations fails them, among them each version number, a droppedconversationIdor target, the owner's timeout counted as a refusal, no reservation, a refused start left reserved, the delivery-id match removed, and non-object frames accepted.pre-commitpasses on the changed files. The journeys weren't run.codex.pygains only the transcript reader the desktop route calls, and the desktop route it serves runs only in a desktop chat, which neither journey drives.Not verified
notes/codex-integration.mdholds that record and how to capture another. The 60 s window before abandoning was chosen, not measured.thread-follower-start-turnis private and could change in any app release. A change that stops the start before it goes out falls back to the queue, and one after it leaves the start to the transcript. The adapter's log,sessions/<session>.codex.log, gives the reason for each. A version bump on discovery reads asno-client-found, the same as no owner.Calls this makes
CODEX_APP_SERVER_WS_URL. That variable does put the app on a server Leaf can reach, which was run too: a second client saw the open chat and started a tool-output turn in it. It reaches every chat and would give the desktop the streamed App Server route, but only for an app launched with it, with a server kept running. The router needs no setup and leaves unowned chats on the queue.leaf delivery readorack.