Repository navigation
Delete the Codex adapter's 20 s bounds on App Server answers and checkout switches - #5994
Merged
Merged
Conversation
…, not 20 s Each App Server request waited at most 20 s for each message (`codex.START_TIMEOUT`), inside two more 20 s bounds on the adapter's start. A full-history `thread/resume` of the largest task on this Mac (3,801 turns, a 44 MB answer) took 9-12 s at load 16 on 18 cores, so at the loads this machine often runs (40-98) it would pass 20 s; the adapter then didn't start, and after a dropped connection it resent the same resume under the same bound for as long as it ran. A request now waits for its answer. The connection's end stops the wait: App Server's exit closes its socket, and websockets' keepalive (a ping every 20 s, 20 s for the pong) closes a connection whose App Server stops answering; it answered every ping during the measured resume, within 2.4 s. `TaskConnection.start` waits for its first connection's outcome without a bound. Switching a task's Leaf checkout waited at most 20 s for the adapter running from the former Leaf to release its lease, though that adapter can be in a 30 s wait between retries. Preparation now waits for the release. Only a caller with a deadline of its own bounds an adapter's preparation. The prompt hook passes its `CONFIRM_WITHIN` deadline through `Harness.preparing_delivery` to the start lock, the switch and the adapter's start, which before took 20 s each, past the hook's 20 s kill, and now share the budget the page server's start already takes (#5973). `claim_and_start` passes its deadline the same way. Commands (`leaf page claim`, `server start`) pass none. Two callers had budgets the per-message bound enforced. `app_server_request` takes an optional `deadline`: inference passes its 60 s cap to every request on the way to an answer, and a request isn't sent once it has passed. The Codex eval arm starts its limit before the task's first request, and giving up stops its App Server, as the Claude arm kills its process group. `START_TIMEOUT` still bounds starts that can hang without closing anything: a spawned App Server's listen (0.1 s measured), a websocket's opening handshake before keepalive runs (40 ms), and the desktop router's start, whose requests carry a timeout. Behavior changes: a slow App Server request, adapter start or checkout switch no longer fails. An App Server that answers pings but never a request now holds that request, and a command waiting on it, until App Server exits, where before the wait ended after 20 s with a refusal. Tests: `test_a_request_waits_for_its_answer_until_the_connection_ends`, `test_a_switch_of_leaf_waits_for_the_former_adapter_however_long_it_takes`, `test_a_hook_behind_another_start_of_delivery_is_refused_at_its_deadline` and `test_an_app_server_that_never_answers_fails_the_request_at_its_deadline`; each fails with its bound or deadline pass-through removed. A website test's fake socket takes `recv`'s optional timeout, as websockets' does. Both Codex journeys (`codex-app-server`, `codex-queue`) pass.
leaf-agent
previously approved these changes
Nov 14, 2026
The earlier commit also passed outside deadlines down to steps the 20 s bounds used to cover: the prompt hook's into adapter preparation and its start lock, inference's 60 s cap into each request, and the eval's limit into its startup. Each covers only an App Server that answers pings but never a request, the case this change accepts, and the hook's adapter start already ran past the hook's kill before #5973. This keeps only the deletions: a request waits for its answer or the connection's close, the adapter's first connection for its outcome, and a checkout switch for the former adapter's exit. Production code is +10/-17 against main.
leaf-agent
approved these changes
Nov 15, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 15, 2026
…ctor alternates (#6013) Max asked for a scan of the whole tree for code like the Codex adapter's 20 s bounds (#5994): mechanisms that guard a case that can't occur or is already covered, and layers with no second user. Nine read-only agents covered `src/leaf`, the browser runtime, the packages, the Worker, the hooks, `build/` and `dev/`. The tree has little of that kind left: no compatibility reads, no validation repeated after an entry point, no deadline plumbing. What remains is mostly options no caller sets and wrappers with one caller. This deletes the ones a reading confirmed, for −70 production lines. Behaviour stays the same except in the dev readers, as the last item says. - Export's CSS traversal carried a `declarations` flag that was always False. - `accept_event`, `PageTransaction.owned_by` and `page_events` only forwarded. `final_text` and `reply_so_far` were the same function. - `createThreadLanding` built a stateless object whose members forwarded to module functions. `landIn`, `landInThread` and `returnToThread` are module exports now. - `stageAuthoredStates` took an `existing` map that every caller passed empty. `presentedControl`'s fallback was applied three times. Margin rows typed four fields optional that their one caller always sets. - Eleven defaults that every caller overrides, in thread code and leaf-dev, are gone. - The dev browser readers still matched `data-mid` and `.lf-thread[data-id]`, which the runtime no longer emits. That made `leaf-dev site verify` miss news on thread cards. They now read `data-lf-event` and the runtime's thread selector, and the website verifier tests' fixtures draw today's DOM. The candidates left alone guard real cases. Draft validation covers records an earlier runtime wrote to localStorage. The unreadable-service branches cover a server started by another Leaf copy on the shared state home. Unreadable-throw handling covers untrusted sample code (#4739). The Worker's per-step timing logs (about 70 lines) have no reader in the repo, but they can be queried on Cloudflare, so they stay unless Max says otherwise. Checks: `pnpm run test:runtime` (974 pass), the browser type check, pre-commit, 191 focused model, process and dev tests, and 11 browser tests over margin pins, obligation walks, replies and the website verifier. > _This was written by Claude Code on behalf of max-sixty_
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.
The Codex adapter gave up on work a loaded machine would finish. Each App Server request waited at most 20 s per message, and a full-history
thread/resumeof the largest task on this Mac (3,801 turns) took 9–12 s at load 16. A checkout switch waited at most 20 s for the former adapter, which can be in a 30 s retry wait. This deletes both bounds and the 20 s on the adapter's first connection: a request waits for its answer or the connection's close (App Server's exit, or websockets' keepalive, which App Server answered throughout that resume), and a switch waits for the former adapter's lease to go. Production code is +10/−17.The risk to weigh: an App Server that answers pings but never a request now holds that request, and any command waiting on it, until App Server exits, where before it was refused after 20 s. Inference's 60 s cap and the eval's limit now cover only their waits for an answer, and a prompt hook that starts an adapter can run past its 20 s kill, as it already could.
Max picked this design in the timeout review. A new model test fails with the per-message bound restored; both Codex journeys pass.