Skip to content

fix(codex): first Codex turn fails on a busy host while the app-server starts - #173716

Merged
vincentkoc merged 3 commits into
mainfrom
codex/stab-codex-cold-acquire
Oct 16, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
codex/stab-codex-cold-acquire

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes the first Codex turn failing on a busy host when discovery times out while the shared app-server is still starting.

User Impact

A caller abandoning discovery no longer cancels shared startup. Later requests can use the ready server, configured startup budgets are honored, and expired acquisitions release their lease without sending a late RPC. Explicit supervision connections keep their existing connection policy.

Why This Change Was Made

The shared service owns physical startup; each caller owns its wait and subsequent request budget. Timeout normalization now uses the config owner without repeating harness connection admission. Timeout diagnostics and control observations retain the phase that failed before successful cleanup, while cleanup-originated failures retain their own phase.

The original contributor's work and ancestry are preserved. The correction was independently reviewed, then integrated through the native baseline workflow with frozen main d4babe8e8ba448bd21bdc4c89de0d223a4353faa.

Evidence

  • Exact prepared source 9a34692c142c9379a21d4971f12cab23eb73a3cd: 159 shared-client tests passed, 92.35s Vitest / 97.64s runner, after a frozen dependency install. This is the suite affected by baseline integration.
  • Reviewed correction 8ee81894d4ed3bba3330422504b421f9776d0a98: 270 request, diagnostic, shared-client and configuration tests passed, 74.73s Vitest / 79.15s runner. The production changes remain byte-identical in the prepared source. Another 21 registration and command tests passed on the prior correction; those paths are unchanged by the final fixes.
  • Reproduced the original two CI failures and five additional supervision/timeout assertions before fixing their causes. The passing tests cover caller cancellation, late lease release, short and long configured startup budgets, explicit connections, and timeout attribution.
  • Independent review found no remaining actionable issue. The only overlapping baseline change is an independently reviewed extraction of the same shared-client test helper sequence. Formatting and diff checks pass.
  • The candidate uses Codex 0.162.0. Its exact release source confirms initialization precedes normal dispatch and closing single-client stdio ends the server.

Validation limits: the original author's busy-host before/after runtime proof applies to the original PR revision. No new live Gateway/provider call or full evaluation run was performed. Before baseline integration, local typed lint stopped at the SDK declaration generator's 300s timeout under host I/O pressure; the subsequent type check lacked those declarations. No local lint/type pass is claimed. The current head uses the enforced PR CI gate for broad validation.

CI disposition

Exact-head CI run 38867771532 completed with 40 successful jobs, 26 skipped jobs, and one inherited lint failure plus its aggregate gate. The sole root error is typescript(consistent-return) in ui/src/pages/debug/debug-overlay.tsx:115, fixed on main by #173976 (8425c9a0cf88a08614785703753dea3c92811feb).

The tested merge 0c185b87b263011369c7009d64b335f491b3e9bb has baseline 0e687614fd9a8b4bca9dde731e1d34348f07366c and this exact PR head as its ordered parents. Its debug-overlay input is byte-identical to that baseline (0ed86224da852044b9b5c81b2b1b71f5ffc83c41); no UI path changes in the PR merge. The aggregate labels it new because the earlier scheduled-main job passed and selected scope was not compared. Native inherited-failure admission uses the inspected job log and unchanged source inputs; this is not a passing full-CI claim.

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T03:23:11.373824Z c38c762 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: codex size: M labels Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c38c762656

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

The PR gives shared Codex app-server startup an independent deadline and starts discovery or control-request budgets after acquisition.

Example: A cold Gateway receives its first Codex message while the host is heavily loaded.

  • Before: Discovery exhausts its 10-second budget during initialization, closes shared startup, and the turn reports an LLM timeout.
  • After: Shared initialization continues within its default 600-second startup budget, and the supplied live run completes with pong.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The central behavior has relevant live evidence, but a configured-timeout defect and two diff-caused CI failures remain.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied live Gateway before/after report exercises a cold first Codex turn on a loaded host: main fails during acquisition, while the changed startup owner permits initialization and the first turn returns pong.
Patch quality 🦪 silver shellfish (2/6) 3 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The first message after Gateway restart can report an LLM timeout while the local Codex app-server is still initializing.
Reason: The maintainer-authored direction addresses an observed first-turn failure without introducing configuration or another lifecycle owner.

Merge readiness

⛔ Needs changes before merge - 3 items remain

Keep this PR open: it addresses a demonstrated cold-start failure, but custom timeout propagation and two stale sibling tests need repair before merge.

Priority: P1
Reviewed head: c38c762656ee4748512822a6a899e7bc116975e2

Before merge

  • Forward canonical plugin configuration through control requests (P2) - codexControlRequest resolves the configured runtime but passes only its request timeout and start options into this scope. With appServer.requestTimeoutMs=120000, these new calculations use an absent pluginConfig and impose a 600000-ms startup limit instead of 1200000 ms; with 10000 configured, startup can instead wait 600000 ms rather than 100000 ms. Forward pluginConfig through controlRequestOptions and audit other callers so both this scope and the physical startup owner use the configured value. This independently confirms the existing review comment.
  • Update the shared registration cancellation expectation (P2) - The existing registration test aborts its caller during process inspection and then requires that no initialize request reached the child. Shared startup now intentionally continues after that caller leaves, so initialization creates requestLogPath and exact-head CI fails at line 341. Split the shared and isolated expectations: retain the isolated no-write check, and verify shared cancellation rejects only its waiter while startup remains lifecycle-owned and is eventually cleaned up.
  • Move the late-acquisition test to the new startup deadline (P2) - The plugin-command test advances 60001 ms and expects acquisition to have exhausted the default 60000-ms request scope. This patch moves acquisition to its separate 600000-ms budget and resets the request deadline after readiness, so that expectation is obsolete and exact-head CI fails at line 303. Update the fixture to exercise expiration of the applicable startup or total scope deadline, while preserving its assertions that a late lease is released and no callback or RPC runs after abandonment.

Findings

  • [P2] Forward canonical plugin configuration through control requests — extensions/codex/src/app-server/request.ts:303-305
  • [P2] Update the shared registration cancellation expectation — extensions/codex/src/app-server/attempt-startup-retry.test.ts:341
  • [P2] Move the late-acquisition test to the new startup deadline — extensions/codex/src/command-plugins-runtime.test.ts:299-303
Agent review details

How this fits together

The Codex plugin acquires and initializes a shared native app-server before model discovery and control requests; it returns leased clients and releases or retires them through the existing lifecycle owner.

flowchart TD
  A[First turn or control request] --> B[Codex request scope]
  B --> C[Shared startup owner]
  C --> D[Native Codex app-server]
  C --> E[Ready client lease]
  E --> F[Discovery or control RPC]
  F --> G[Lease release and idle retirement]
Loading

Technical review

Best possible solution:

Retain independent shared startup, forward canonical configuration through control callers, and align sibling coverage with the new lifetime contract.

Do we have a high-confidence way to reproduce the issue?

Current-main source shows discovery sharing its short deadline with acquisition and final-waiter cleanup; the author additionally supplies matching live before/after results, although this review ran no target code.

Is this the best way to solve the issue?

Separating service-owned startup from caller request budgets fixes the owning lifecycle rather than adding retries, but configuration must reach both startup-budget calculations.

Full review comments:

  • [P2] Forward canonical plugin configuration through control requests — extensions/codex/src/app-server/request.ts:303-305
    codexControlRequest resolves the configured runtime but passes only its request timeout and start options into this scope. With appServer.requestTimeoutMs=120000, these new calculations use an absent pluginConfig and impose a 600000-ms startup limit instead of 1200000 ms; with 10000 configured, startup can instead wait 600000 ms rather than 100000 ms. Forward pluginConfig through controlRequestOptions and audit other callers so both this scope and the physical startup owner use the configured value. This independently confirms the existing review comment.
    Confidence: 0.99
  • [P2] Update the shared registration cancellation expectation — extensions/codex/src/app-server/attempt-startup-retry.test.ts:341
    The existing registration test aborts its caller during process inspection and then requires that no initialize request reached the child. Shared startup now intentionally continues after that caller leaves, so initialization creates requestLogPath and exact-head CI fails at line 341. Split the shared and isolated expectations: retain the isolated no-write check, and verify shared cancellation rejects only its waiter while startup remains lifecycle-owned and is eventually cleaned up.
    Confidence: 0.99
  • [P2] Move the late-acquisition test to the new startup deadline — extensions/codex/src/command-plugins-runtime.test.ts:299-303
    The plugin-command test advances 60001 ms and expects acquisition to have exhausted the default 60000-ms request scope. This patch moves acquisition to its separate 600000-ms budget and resets the request deadline after readiness, so that expectation is obsolete and exact-head CI fails at line 303. Update the fixture to exercise expiration of the applicable startup or total scope deadline, while preserving its assertions that a late lease is released and no callback or RPC runs after abandonment.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 138486fc13fd.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test extensions/codex/src/app-server/request.test.ts extensions/codex/src/app-server/shared-client.test.ts --maxWorkers=1
  • pnpm test extensions/codex/src/app-server/attempt-startup-retry.test.ts extensions/codex/src/command-plugins-runtime.test.ts --maxWorkers=1
  • pnpm test extensions/codex/src/app-server/attempt-timeouts.test.ts extensions/codex/src/app-server/model-catalog.test.ts --maxWorkers=1
  • git diff --check

What I checked:

Likely related people:

  • Vincent Koc: Raw commit c1683a6 adds extensions/codex/src/app-server/shared-client-lifecycle.ts:39 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c1683a687418; files: extensions/codex/src/app-server/shared-client-lifecycle.ts)

PR surface

Source 0, Tests +27, Docs +9. Total +36 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 108 108 0
Tests 4 117 90 +27
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 234 198 +36

Labels

Label changes:

  • add P1: The supplied live reproduction shows a first Codex agent turn failing after Gateway restart on a busy host before any model request is made.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: The supplied live reproduction shows a first Codex agent turn failing after Gateway restart on a busy host before any model request is made.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 15, 2026, 11:34 PM ET / October 16, 2026, 03:34 UTC.

@vincentkoc
vincentkoc enabled auto-merge (squash) October 16, 2026 07:33
@vincentkoc vincentkoc self-assigned this Oct 16, 2026
@vincentkoc
vincentkoc disabled auto-merge October 16, 2026 07:41
@vincentkoc
vincentkoc merged commit 5ad0710 into main Oct 16, 2026
129 of 132 checks passed
@vincentkoc
vincentkoc deleted the codex/stab-codex-cold-acquire branch October 16, 2026 07:45
@vincentkoc

Copy link
Copy Markdown
Member

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: codex P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants