Repository navigation
feat(codex): prefer newer installed Codex for ChatGPT discovery - #168228
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR prefers a qualified newer installed Codex for managed turns and reports its version during ChatGPT model discovery. Example: The Gateway has bundled Codex 0.160.0 and installed Codex 0.162.1 on PATH.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it implements an approved, useful runtime-selection change that current main does not provide, with no actionable introduced defect found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Codex plugin selects the executable for managed stdio startup; the Gateway carries that selection's version into catalog workers, which construct OpenAI discovery requests. flowchart TD
A[Gateway request] --> B[Codex selection owner]
B --> C[Installed executable probe]
B --> D[Bundled fallback]
B --> E[Managed app server]
B --> F[Catalog worker handoff]
F --> G[ChatGPT model discovery]
Technical reviewBest possible solution: Land the approved selection policy with bundled fallback and parent-owned discovery handoff through the native CI exception workflow. Do we have a high-confidence way to reproduce the issue? This is an intentional capability change: current-main source confirms managed startup and ChatGPT discovery remain tied to the bundle. Is this the best way to solve the issue? The approach keeps selection in the Codex owner, preserves override precedence, and carries one decision into workers; its remaining protocol and catalog timing limits are documented and accepted. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e3415ea8c554. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +933, Tests +1001, Docs +77, Config +7, Other +2. Total +2020 across 48 files. Added test files: 5. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (9 earlier review cycles; latest 8 shown)
Reviewed October 10, 2026, 8:05 AM ET / 12:05 UTC (Revision 10). |
…ateway's client version to catalog workers
…moval, or desktop-first starts
… the bundled fallback
…native executable
|
Approved direction for this PR: prefer an installed Codex only when it is strictly newer than the bundled one, same major version, and passes a real startup handshake; otherwise use the bundled Codex. Explicit |
11093c3 to
5a2059e
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
🦞👀 Re-review progress:
|
|
The two newly exposed non-Codex failures reproduce on this PR's exact clean main parent, After OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1 OPENCLAW_VITEST_MAX_WORKERS=2 \
node scripts/run-vitest.mjs run \
--config test/vitest/vitest.extension-database-workers.config.ts \
--configLoader runner --maxWorkers 2 \
extensions/memory-core/src/memory/manager-search-reindex-backoff.test.ts \
extensions/agentsapi/agentsapi-attempt.test.tsResult: 2 files failed; 5 tests failed and 13 passed.
These are the same assertions reported by integrated-head CI run 38049166366. They are inherited main failures, not effects of the Codex client-version handoff. No assertions were changed, retried, or suppressed, and no unrelated source fixes were made. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…claw#168228) Prefer a validated newer stable same-major Codex CLI on PATH for managed turns, and carry the selected client version into ChatGPT model discovery. Return to the bundled runtime when it catches up or the installed candidate fails qualification/startup. Bound cold selection, retain shared fallback ownership and explicit/desktop precedence, isolate probe storage, and skip selection for unrelated catalog and auth-only requests. Production-authenticated ChatGPT discovery and turns remain unproven; same-major post-initialize protocol compatibility is an accepted residual risk. Co-authored-by: obviyus <[email protected]> Co-authored-by: steipete <[email protected]>
openclaw#168228 (1120acc) exported InstalledCodexAppServer, but only managed-binary.ts uses it, so the CI deadcode:exports scan fails on main.
What Problem This Solves
ChatGPT can offer models to a newer installed Codex before OpenClaw updates its bundled Codex, but managed turns and discovery currently remain pinned to the bundled version.
User Impact
Managed Codex turns can use a newer stable same-major Codex already on
PATH, and ChatGPT discovery sends that selection asclient_version. No installation is performed and the selected OpenClaw agent runtime does not change.Explicit commands, environment overrides, remote app-servers, and macOS desktop-first Computer Use keep their existing precedence. Login-status probes, node exec-servers, and the Doctor package check continue using the bundled package.
Why This Change Was Made
The Codex plugin remains the single selection owner. It accepts native executables and the official npm launcher, requires a parseable stable version newer than the bundle and in the same major, and proves a real
initializehandshake against an isolated throwawayCODEX_HOME. It otherwise uses bundled@openai/[email protected]. Version and handshake checks share a four-second cold-selection budget; requests with less time spend at most half their remaining deadline on selection. A timeout selects the bundled pin and ignores late success, preserving time for bundled startup. A selected binary that later fails startup or changes version yields to the bundle before any thread or turn, and remains rejected until Gateway restart.Desktop-owned macOS binaries are not adopted through PATH aliases. The selection probe forces its SQLite location as well as its Codex home into temporary storage, and skips probing when system/managed requirements can override that location. Explicit and desktop-first connections retain their existing ownership rules.
The private-local
plugin-sdk/codex-client-version-runtimefacade exposesresolveCodexClientVersion({ config, env, agentDir }). Catalog requests that can reach OpenAI carry the parent Gateway's captured decision into their worker, rather than allowing the worker to select a different binary. Unrelated-provider and auth-only requests do not probe Codex. The version is included in the existing catalog cache key.This deliberately revises the PATH-independent default in #71808 while retaining its safeguards: an older CLI below the protocol floor is not selected; a failing handshake falls back; the plugin-owned dependency remains staged and available; and selecting a binary does not change the auth-home policy. Related behavior in #71842, #100973, #127394, #149647, #150255, #152181, #156187, #156671, and #158703 remains unchanged outside the documented binary-selection change.
The automatic-selection direction and residual same-major protocol risk have explicit maintainer approval.
Known, accepted limitations: a model-list request captured before a first-use rejection can finish with the previous version, including when capture precedes worker-pool admission. Already-cached ChatGPT model rows can remain for about 60 seconds. A standalone CLI selects in its own process and can disagree with a Gateway started later. More importantly, a newer same-major Codex can pass
initializeand still change later protocol semantics; compatibility beyond that handshake is not proven. These windows and the protocol risk are documented, not hidden by automatically changing the OpenClaw runtime.Evidence
11093c3: cold selection does not settle within the caller budget, and unrelated/auth-only worker requests call the Codex resolver twice. The repaired tests pass; config/env overrides and rejected concurrent-start fallback also pass.preferInstalled: false), so a newer PATH Codex cannot attest a missing or mismatched bundled dependency.client_versionremain unproven. Synthetic provider responses establish the emitted request parameter, not model availability or later protocol compatibility.Runtime matrix
The Linux cells run the installed candidate package through Gateway
models.list, with a synthetic HTTPS ChatGPT endpoint and synthetic token. TLS verification and the normal SSRF guard remain enabled. All 18 cells passed, including readiness, the selection log, emittedclient_version, authorization, and hung-probe cleanup checks.ok; Gateway ready before/after;client_versionchanges from 0.158.0 to 0.162.1; Doctor managed-package check passesThe update retained the same synthetic auth profile and used it successfully after cutover. These package/runtime cells were executed on
ea2e956; the subsequent main merge did not alter the Codex or OpenAI implementation. The current integrated head is checked separately by CI.CI context
Integrated-head CI completed with inherited failures in unchanged areas; no required lane remains unrun. The corresponding main evidence is:
test/cli-json-stdout.models.e2e.test.ts:173also fails on clean main78e6318772e0bcd6aa79cb14d1b1ed2bbd2c39a7, with the same missing “A running Gateway applies the update on its next catalog check” message.45c7bc9: 5 failed / 13 passed, with identical assertions and the same owning test configuration.managed-cleanup-handoff.mtsand native-launch cleanup-parent environment mismatch are also present on main.No unrelated source or failing assertion was changed to make this PR pass.
Merge Danger
Two-way door: reverting restores the bundled-only managed default; this change adds no config, dependency bump, durable state, or data migration. Blast radius is managed Codex stdio turns and ChatGPT model discovery on hosts with a newer accepted PATH Codex. A later same-major protocol incompatibility can still break such turns; operators can pin
appServer.commandor remove that executable from the Gateway PATH. Existing explicit/remote/desktop-first behavior is not broadened.