Repository navigation
fix(codex): back off between app-server startup retries - #129505
Conversation
A transient Codex app-server startup exit could burn all three startup attempts inside one contention window: codex 0.149.1 hard-fails StateRuntime::init after its five-second SQLite busy timeout when another Codex instance (e.g. Codex Desktop) is actively using the same codex home, and the startup loop restarted immediately, so attempts 1-3 raced the same held lock roughly six seconds apart and onboarding's Codex candidate died with 'initialize transport failed after request write'. The same activation retried later succeeds in one attempt. Keep the canonical three-attempt owner but wait 1s before attempt 2 and 2s before attempt 3 (zero for executable-selection changes), abortable via the existing startup abandonment signal. Non-transport errors still fail immediately. Production LOC net-neutral. Upstream contract verified in ../codex at rust-v0.149.1: app-server/src/lib.rs:613 (fatal init), rollout/src/state_db.rs:45 (CLI warns instead), state/src/sqlite.rs:285 (5s busy_timeout). Four hermetic child-process regressions: first-spawn exit recovers; contention outlasting immediate retries recovers only with backoff (fails pre-fix); persistent exits stop at three attempts; unsupported version fails after one.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 2:42 PM ET / 18:42 UTC. ClawSweeper reviewWhat this changesThe PR makes retriable Codex app-server startup failures wait 1 then 2 seconds before bounded retries, with child-process regression coverage for transient SQLite contention. Regression provenancePossible regression — suspected (failure trace; reviewed change). No predecessor PR is attributed. Merge readinessKeep open for maintainer handling. The patch is structurally focused and no discrete code defect was found, but the required direct Codex 0.149.1 contract inspection is blocked because the sibling checkout is absent and network DNS could not fetch it; the PR also carries the protected Priority: P1 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe bundled Codex plugin starts an app-server process for embedded agent runs and onboarding. Its startup owner classifies failures, manages the shared client lease, and either opens a thread or reports a startup diagnostic. flowchart LR
A[Onboarding or embedded run] --> B[Codex plugin]
B --> C[App-server startup owner]
C --> D{Startup outcome}
D -->|Closed transport| E[Clear client and bounded retry]
D -->|Other error| F[Startup diagnostic]
E --> G[Shared app-server client]
G --> H[Codex thread]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +214. Total +214 across 3 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Restore access to the exact Codex 0.149.1 source, verify the failure contract, and then land the canonical bounded retry with a redacted after-fix contention recovery trace. Do we have a high-confidence way to reproduce the issue? No high-confidence current-main execution was performed: source proves the immediate-retry owner and the PR supplies a child-process scenario, but tests were not run in this read-only review and the upstream Codex source is unavailable. Is this the best way to solve the issue? Unclear. The patch keeps the retry owner, classifier, cap, and cancellation boundary coherent, but the dependency contract and claimed live recovery still need direct verification. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8bfcdbe884ce. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
#129505 added attempt-startup-retry.test.ts without registering it in the attempt-support shard, so vitest-projects-config's exactly-once coverage check fails on every PR merge-ref (checks-node-compact-large-11).
#129505 added extensions/codex/src/app-server/attempt-startup-retry.test.ts without lane ownership, so the full-suite coverage guard (test/vitest-projects-config.test.ts) fails on every full run. Register it beside attempt-startup.test.ts in the attempt-support lane.
…124301) * improve(control-ui): align composer stack with current main * refactor(ui): isolate new-session permission state * fix(ui): close composer CI regressions * test(ui): align composer presentation contracts * test(ui): fix composer browser contracts * test(ui): stabilize composer browser ownership * test(ui): target presented mobile composer * test(ui): select accessible mobile composer * test(ui): open mobile rail session directly * fix(ui): keep mobile composer content laid out * fix(ui): address composer review findings * fix(ui): close composer interaction gaps * fix(ui): bound swarm task popover * fix(ui): restore progress-card docking beside the wide composer The multiline restructure dropped the .session-progress-card--dock placement shipped in #129141 and left the completed marker inside the collapsed-only summary span, so it vanished when the disclosure opened. Restore the dock positioning block and hoist the marker into the always-visible summary grid. * fix(ui): bound swarm task popover by its composer anchor The popover capped its height against the raw viewport, so on short mobile viewports its top rendered above the screen. Register the swarm group with the existing composer popover anchor observer and consume the measured --chat-composer-popover-max-height, keeping the viewport calc only as fallback. The new actual-tree mobile regression failed with -71px top clipping before the fix. * fix(ui): restore Draft capability controls and split the new-session composer Restores the Draft option and selected-state indicators the capability menu lost in the restructure, and moves the capability/visibility controls into composer-capability-controls.ts so composer.ts drops back under the 700-line lint gate (677 lines) without a suppression. * test(ui): prove permission-mode final effect before session creation Adds mocked-gateway proof that an admin's Full selection reaches sessions.create as permissionMode:"full" exactly once, and that a write-scoped operator's retained Full selection is rejected before creation with a visible status notice and zero create requests. Also aligns the mobile footer reading-order assertion with the shipped attachments-draft-model order. * test(ui): register swarm popover layout test as node-driven chat-swarm-progress.browser.test.ts drives its own Playwright chromium from node, but d3396c4 added it without registering it in nodeDrivenBrowserLayoutTests, so the browser-mode chromium project tried to fetch it into the page and failed on the node-only playwright import. This was the deterministic checks-ui failure on both prior heads. * test(ci): register codex attempt-startup-retry in its support lane #129505 added extensions/codex/src/app-server/attempt-startup-retry.test.ts without lane ownership, so the full-suite coverage guard (test/vitest-projects-config.test.ts) fails on every full run. Register it beside attempt-startup.test.ts in the attempt-support lane. * test(ui): expect last-activity suffix in composer summary label Merge weave: #129520 appends the accessible last-activity to the summary aria-label; align the restructured composer card's assertion with it. --------- Co-authored-by: Peter Steinberger <[email protected]>
) * fix(codex): back off between app-server startup retries A transient Codex app-server startup exit could burn all three startup attempts inside one contention window: codex 0.149.1 hard-fails StateRuntime::init after its five-second SQLite busy timeout when another Codex instance (e.g. Codex Desktop) is actively using the same codex home, and the startup loop restarted immediately, so attempts 1-3 raced the same held lock roughly six seconds apart and onboarding's Codex candidate died with 'initialize transport failed after request write'. The same activation retried later succeeds in one attempt. Keep the canonical three-attempt owner but wait 1s before attempt 2 and 2s before attempt 3 (zero for executable-selection changes), abortable via the existing startup abandonment signal. Non-transport errors still fail immediately. Production LOC net-neutral. Upstream contract verified in ../codex at rust-v0.149.1: app-server/src/lib.rs:613 (fatal init), rollout/src/state_db.rs:45 (CLI warns instead), state/src/sqlite.rs:285 (5s busy_timeout). Four hermetic child-process regressions: first-spawn exit recovers; contention outlasting immediate retries recovers only with backoff (fails pre-fix); persistent exits stop at three attempts; unsupported version fails after one. * chore: drop worker scratch file
…penclaw#124301) * improve(control-ui): align composer stack with current main * refactor(ui): isolate new-session permission state * fix(ui): close composer CI regressions * test(ui): align composer presentation contracts * test(ui): fix composer browser contracts * test(ui): stabilize composer browser ownership * test(ui): target presented mobile composer * test(ui): select accessible mobile composer * test(ui): open mobile rail session directly * fix(ui): keep mobile composer content laid out * fix(ui): address composer review findings * fix(ui): close composer interaction gaps * fix(ui): bound swarm task popover * fix(ui): restore progress-card docking beside the wide composer The multiline restructure dropped the .session-progress-card--dock placement shipped in openclaw#129141 and left the completed marker inside the collapsed-only summary span, so it vanished when the disclosure opened. Restore the dock positioning block and hoist the marker into the always-visible summary grid. * fix(ui): bound swarm task popover by its composer anchor The popover capped its height against the raw viewport, so on short mobile viewports its top rendered above the screen. Register the swarm group with the existing composer popover anchor observer and consume the measured --chat-composer-popover-max-height, keeping the viewport calc only as fallback. The new actual-tree mobile regression failed with -71px top clipping before the fix. * fix(ui): restore Draft capability controls and split the new-session composer Restores the Draft option and selected-state indicators the capability menu lost in the restructure, and moves the capability/visibility controls into composer-capability-controls.ts so composer.ts drops back under the 700-line lint gate (677 lines) without a suppression. * test(ui): prove permission-mode final effect before session creation Adds mocked-gateway proof that an admin's Full selection reaches sessions.create as permissionMode:"full" exactly once, and that a write-scoped operator's retained Full selection is rejected before creation with a visible status notice and zero create requests. Also aligns the mobile footer reading-order assertion with the shipped attachments-draft-model order. * test(ui): register swarm popover layout test as node-driven chat-swarm-progress.browser.test.ts drives its own Playwright chromium from node, but d3396c4 added it without registering it in nodeDrivenBrowserLayoutTests, so the browser-mode chromium project tried to fetch it into the page and failed on the node-only playwright import. This was the deterministic checks-ui failure on both prior heads. * test(ci): register codex attempt-startup-retry in its support lane openclaw#129505 added extensions/codex/src/app-server/attempt-startup-retry.test.ts without lane ownership, so the full-suite coverage guard (test/vitest-projects-config.test.ts) fails on every full run. Register it beside attempt-startup.test.ts in the attempt-support lane. * test(ui): expect last-activity suffix in composer summary label Merge weave: openclaw#129520 appends the accessible last-activity to the summary aria-label; align the restructured composer card's assertion with it. --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
During a live fresh-profile macOS onboarding round (obt826, app + gateway at main 203024e), the Codex candidate's live test failed after 48s with
initialize transport failed after request write: codex app-server exited: code=1 ... failed to initialize sqlite state runtime under ~/.codex, and onboarding dropped the user's Codex provider:The exit itself is an upstream contract: codex 0.149.1's app-server path hard-fails
StateRuntime::initafter its five-second SQLite busy timeout when another Codex instance (here: a running Codex Desktop) actively uses the same codex home — the codex CLI path merely warns on the identical failure and continues (verified in the sibling../codexcheckout atrust-v0.149.1:codex-rs/app-server/src/lib.rs:613,codex-rs/rollout/src/state_db.rs:45,codex-rs/state/src/sqlite.rs:285).The OpenClaw defect: the canonical three-attempt startup loop in
extensions/codex/src/app-server/attempt-startup.tsrestarted immediately, so all three attempts raced the same held-lock window ~6s apart (structured gateway log shows attempts 1→2→3 exhausted at 08:23:07/13/19 UTC). The identicalopenclaw.setup.activateretried later succeeded in a single attempt ("Inference verified: openai/gpt-5.6-sol", 27s) — the failure class is provably transient.Why This Change Was Made
Keep the existing bounded three-attempt owner and closed-transport classifier, but wait 1s before attempt 2 and 2s before attempt 3 (zero delay for executable-selection changes), using the existing
sleepWithAbortwith the startup abandonment signal so cancellation still rejects promptly. Non-transport errors (unsupported version, auth) still fail on the first attempt. This does not mask persistent failures — retries remain capped at three — and does not add a second startup path. Production LOC is net-neutral (13+/13−).User Impact
Onboarding and any Codex app-server startup survive the common "Codex Desktop is also running" contention window instead of failing the whole candidate; genuinely broken setups still fail fast with the same diagnostics.
Evidence
attempt-startup.tsguarded loop →shared-client.tsinitialize (details in commit message).attempt-startup-retry.test.ts): first-spawn SQLite exit recovers on attempt 2; a contention window that defeats immediate retries recovers only with backoff (fails pre-fix); persistent exits stop after exactly three attempts; unsupported version fails after exactly one.check-changedgreen. Autoreview clean ("patch is correct (0.99)").