Repository navigation
fix: list ChatGPT models with a Codex client version - #202284
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR uses the latest stable Codex version for ChatGPT model discovery, with shared caching and a bounded bundled-version fallback. Example: OpenClaw 2026.11.5 discovers subscription models while npm reports Codex 0.171.0.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review The previous timeout finding is resolved, and no new actionable defects were found in this PR; required CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe OpenAI plugin resolves a discovery client version, requests the signed-in account's ChatGPT catalog, and publishes model rows through the existing catalog owner. flowchart LR
A[Catalog discovery] --> B[OpenAI plugin]
B --> C[Shared version cache]
C --> D[npm stable version]
C --> E[Bundled version fallback]
B --> F[ChatGPT model endpoint]
F --> G[Published model catalog]
Technical reviewBest possible solution: Keep version selection in the OpenAI plugin using the existing guarded transport and catalog cache, with the repaired registry deadline. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically sends OpenClaw's calendar version to the Codex model endpoint; inspection establishes the version-stream mismatch, without demonstrating a current backend rejection. Is this the best way to solve the issue? The implementation restores a documented, owner-approved Codex version policy, removes the replaced calendar selector, and reuses existing transport and cache owners; the fixture relocation preserves existing assertions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3e7c305f4572. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +59, Tests +181, Docs 0. Total +240 across 15 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 (1 earlier review cycle)
Reviewed November 20, 2026, 1:29 AM ET / 06:29 UTC (Revision 2). |
|
@clawsweeper re-review Fixed the npm timeout finding in 8944801. The new owning-boundary regression fails with the previous timeout and passes with the one-second timeout; the PR evidence is current. |
|
🦞👀 Re-review progress:
|
…202380) Supersedes #202284. Restores the approach of #201493. Related: #201130. ## What Problem This Solves ChatGPT subscription model discovery calls `/backend-api/codex/models?client_version=<X>`, and the backend hides every model whose `minimal_client_version` is above X. On main (#202284), X comes from a lookup of the latest `@openai/codex` on npm, cached in memory for six hours. That puts a registry request (1 s budget) on the model-listing path. A failed or slow lookup lists at the bundled 0.169.0 floor and can hide newly launched models. The in-memory cache also does not survive a restart or eviction. ## Solution - List with the OpenClaw release that OpenClaw-harness Responses turns already send as the `version` header (provider attribution). The list and the turn use one value from one owner. - Send only the numeric `YYYY.M.P` part (year 2026 or later). For example, `2026.11.5-beta.1` lists as `2026.11.5`. Anything else (`unknown`, `0.0.0-dev`, a bad `OPENCLAW_VERSION` override, or a proxy without attribution headers) lists as `99.0.0`. - Treat an empty subscription list as a failed listing. A ChatGPT account always has models, so an empty 200 response keeps the last good rows instead of replacing them. API-key access-program discovery, where an empty list is valid, is unchanged. - Delete the npm lookup, the six-hour cache, the 0.169.0 floor, the floor contract test, and the test mocks that existed only for them. Production: +19 / −74 lines. - Keep the Responses `version` header unchanged. Keep Codex binary selection and update behavior unchanged. Why this replaces the earlier designs: - #201130 and #202284 needed a network request for a value the backend only compares numerically. Any version at or above a model's minimum shows the model. - Peer clients hardcode a value for the same reason: Hermes `99.0.0`, Zed `0.999.0`, Crush `999.0.0`. - #202284's concern was that an OpenClaw version goes into a Codex-version parameter. The same value already passes the same gate on every Responses turn, and an npm-latest value does not describe the binary that runs a turn either. - A version starting with 2026 stays above every Codex 0.x release, so new models appear on launch day without a lookup. - The version check is stricter than #201493's: suffixes are dropped instead of sent, because no live probe has tested a prerelease string. Accepted edge cases (code comment in `base-url.ts`): - A Codex-harness binary older than a listed model fails that turn with the existing update instructions and **Start a new session** (#201130). npm-latest had the same tradeoff. - An old OpenClaw release can list a future model whose request shape it does not support yet. Every fixed-version and npm-latest approach has this. I also considered an omp-style background npm refresh with persistence (oh-my-pi `codex-version.ts`). Plugin keyed state is unavailable in the catalog worker threads where discovery runs (`Shared-state admission requires the host broker`). An in-memory variant still needed a network request and reset to the floor on every restart. ## User Impact - ChatGPT subscription users see newly launched models without an OpenClaw release, without a network lookup, and without depending on npm availability. - Listing makes one request: the ChatGPT `/models` call. - A transient empty model list from ChatGPT no longer clears the model picker. ## Evidence - **Red on main, green on the fix** (`extensions/openai/openai-codex-discovery.test.ts`): - The version-table cases fail on main, which makes two requests (npm, then `/models`). The fix makes exactly one, to chatgpt.com, with the expected `client_version`. - The empty-list case fails on main (`expected ['ready'] to deeply equal ['unavailable']`) and passes on the fix. - Main result: 14 of 16 failed (the 2 GPT-6.1 Sol cases pass on both). - **Focused suites green:** `openai-codex-discovery`, `openai-provider`, `openai-provider.codex-catalog`, `openai-api-key-catalog`, `platform-access-programs`, `base-url`, `src/plugins/contracts/provider-live-listing.contract.test.ts`, `test/openai-model-discovery-auth-order.test.ts`, `test/model-account-catalog-authority.integration.test.ts`. - **Live, real ChatGPT Pro login (2026-11-18 probe):** - `client_version` 2026.11.5, 0.166.0, 0.169.0 and 99.0.0 return the same 13 models, including `gpt-6.2-sol` and `gpt-6.2-astra` (`minimal_client_version` 0.166.0). - 0.164.0 and 0.165.0 hide GPT-6.2. 0.0.0 returns a frozen legacy list of 7 models. - `/responses` with `version: 2026.11.5` on `gpt-6.2-sol` returns 200. - **End to end on this branch** (isolated Gateway from source, fresh ChatGPT device-code login, nothing live touched): - `models.list` returned 11 subscription models with outcome `ready`, including `gpt-6.2-sol` (1.05M context) and `gpt-6.2-astra`. - The Gateway log shows no `registry.npmjs.org` request. - A real turn on `openai/gpt-6.2-sol` returned `CXV_OK2`. - The same account listed identical models at 0.169.0 and 0.171.0 earlier today. No live model is currently gated between the bundled pin and npm latest, so the "floor hides a model" case was proven in tests, not live. - **Not proven live:** a Gateway with `OPENCLAW_VERSION=unknown` (the dev tooling strips `OPENCLAW_*`). The version table covers that fallback. ## Merge Risk Two-way door: no state, schema, config or published contract changes, and a revert fully restores the npm lookup. Blast radius: ChatGPT subscription model listing for OpenAI OAuth and token profiles. API-key listing, Responses headers and Codex binary selection are unchanged. Co-authored-by: Daniel <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
* fix(openai): use Codex client versions for ChatGPT model discovery * fix(openai): reserve model discovery budget after npm timeout
…penclaw#202380) Supersedes openclaw#202284. Restores the approach of openclaw#201493. Related: openclaw#201130. ## What Problem This Solves ChatGPT subscription model discovery calls `/backend-api/codex/models?client_version=<X>`, and the backend hides every model whose `minimal_client_version` is above X. On main (openclaw#202284), X comes from a lookup of the latest `@openai/codex` on npm, cached in memory for six hours. That puts a registry request (1 s budget) on the model-listing path. A failed or slow lookup lists at the bundled 0.169.0 floor and can hide newly launched models. The in-memory cache also does not survive a restart or eviction. ## Solution - List with the OpenClaw release that OpenClaw-harness Responses turns already send as the `version` header (provider attribution). The list and the turn use one value from one owner. - Send only the numeric `YYYY.M.P` part (year 2026 or later). For example, `2026.11.5-beta.1` lists as `2026.11.5`. Anything else (`unknown`, `0.0.0-dev`, a bad `OPENCLAW_VERSION` override, or a proxy without attribution headers) lists as `99.0.0`. - Treat an empty subscription list as a failed listing. A ChatGPT account always has models, so an empty 200 response keeps the last good rows instead of replacing them. API-key access-program discovery, where an empty list is valid, is unchanged. - Delete the npm lookup, the six-hour cache, the 0.169.0 floor, the floor contract test, and the test mocks that existed only for them. Production: +19 / −74 lines. - Keep the Responses `version` header unchanged. Keep Codex binary selection and update behavior unchanged. Why this replaces the earlier designs: - openclaw#201130 and openclaw#202284 needed a network request for a value the backend only compares numerically. Any version at or above a model's minimum shows the model. - Peer clients hardcode a value for the same reason: Hermes `99.0.0`, Zed `0.999.0`, Crush `999.0.0`. - openclaw#202284's concern was that an OpenClaw version goes into a Codex-version parameter. The same value already passes the same gate on every Responses turn, and an npm-latest value does not describe the binary that runs a turn either. - A version starting with 2026 stays above every Codex 0.x release, so new models appear on launch day without a lookup. - The version check is stricter than openclaw#201493's: suffixes are dropped instead of sent, because no live probe has tested a prerelease string. Accepted edge cases (code comment in `base-url.ts`): - A Codex-harness binary older than a listed model fails that turn with the existing update instructions and **Start a new session** (openclaw#201130). npm-latest had the same tradeoff. - An old OpenClaw release can list a future model whose request shape it does not support yet. Every fixed-version and npm-latest approach has this. I also considered an omp-style background npm refresh with persistence (oh-my-pi `codex-version.ts`). Plugin keyed state is unavailable in the catalog worker threads where discovery runs (`Shared-state admission requires the host broker`). An in-memory variant still needed a network request and reset to the floor on every restart. ## User Impact - ChatGPT subscription users see newly launched models without an OpenClaw release, without a network lookup, and without depending on npm availability. - Listing makes one request: the ChatGPT `/models` call. - A transient empty model list from ChatGPT no longer clears the model picker. ## Evidence - **Red on main, green on the fix** (`extensions/openai/openai-codex-discovery.test.ts`): - The version-table cases fail on main, which makes two requests (npm, then `/models`). The fix makes exactly one, to chatgpt.com, with the expected `client_version`. - The empty-list case fails on main (`expected ['ready'] to deeply equal ['unavailable']`) and passes on the fix. - Main result: 14 of 16 failed (the 2 GPT-6.1 Sol cases pass on both). - **Focused suites green:** `openai-codex-discovery`, `openai-provider`, `openai-provider.codex-catalog`, `openai-api-key-catalog`, `platform-access-programs`, `base-url`, `src/plugins/contracts/provider-live-listing.contract.test.ts`, `test/openai-model-discovery-auth-order.test.ts`, `test/model-account-catalog-authority.integration.test.ts`. - **Live, real ChatGPT Pro login (2026-11-18 probe):** - `client_version` 2026.11.5, 0.166.0, 0.169.0 and 99.0.0 return the same 13 models, including `gpt-6.2-sol` and `gpt-6.2-astra` (`minimal_client_version` 0.166.0). - 0.164.0 and 0.165.0 hide GPT-6.2. 0.0.0 returns a frozen legacy list of 7 models. - `/responses` with `version: 2026.11.5` on `gpt-6.2-sol` returns 200. - **End to end on this branch** (isolated Gateway from source, fresh ChatGPT device-code login, nothing live touched): - `models.list` returned 11 subscription models with outcome `ready`, including `gpt-6.2-sol` (1.05M context) and `gpt-6.2-astra`. - The Gateway log shows no `registry.npmjs.org` request. - A real turn on `openai/gpt-6.2-sol` returned `CXV_OK2`. - The same account listed identical models at 0.169.0 and 0.171.0 earlier today. No live model is currently gated between the bundled pin and npm latest, so the "floor hides a model" case was proven in tests, not live. - **Not proven live:** a Gateway with `OPENCLAW_VERSION=unknown` (the dev tooling strips `OPENCLAW_*`). The version table covers that fallback. ## Merge Risk Two-way door: no state, schema, config or published contract changes, and a revert fully restores the npm lookup. Blast radius: ChatGPT subscription model listing for OpenAI OAuth and token profiles. API-key listing, Responses headers and Codex binary selection are unchanged. Co-authored-by: Daniel <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #201130, #201493
What Problem This Solves
ChatGPT subscription model discovery sends OpenClaw's calendar version to a Codex-maintained API. The backend's client-version gates therefore receive a version from the wrong release stream.
User Impact
Subscription discovery reports a stable Codex client version independently of OpenClaw releases. The first discovery after cache expiry can wait up to one second for npm; a registry failure still allows discovery using the bundled Codex version.
Why This Change Was Made
Resolve npm's latest stable
@openai/codexversion, cache successful lookups for six hours, and use bundled Codex0.169.0as both the minimum and registry-failure fallback. Failed lookups are retried on the next discovery attempt. Responses attribution and Codex binary selection/update behavior remain independent.This removes the calendar-version/
99.0.0selection and reuses the existing guarded HTTP transport and catalog cache. A contract test keeps the floor aligned with the bundled dependency; test planning schedules that contract for pin changes. The existing Responses wrapper fixture moves into its existing support module to satisfy the line-cap ratchet, with its assertions preserved.Evidence
2026.11.5where the Codex version was expected. The corrected discovery and provider contracts pass./backend-api/codex/models?client_version=0.171.0HTTP 200; 10 available models; a real OpenClaw-runtime turn returnedCODEX_DISCOVERY_OK. Responses usedoriginator=openclawandversion=2026.11.5. The test Gateway was stopped after validation.140e6bf92c820eb9d7592c285106b62668319d50reported scoped-clean at P0–P2. This predates the unchanged fixture relocation and timeout repair. Local ClawSweeper was unavailable because its source checkout lacks dependencies and build output. Hosted ClawSweeper reviewed5387637c75960f946bb212c6415e69172f953862and found one P2: npm could consume the entire five-second discovery budget.runProviderCatalogWithTimeoutfails with the old five-second timeout and passes with the fix: a stalled registry falls back to bundled Codex and still publishes models from a healthy endpoint within the existing owner budget. All 40 provider-listing contracts and 10 discovery tests passed; the new regression passed again after lint/format cleanup. Targeted typecheck, lint, formatting, and commit hooks passed. Hosted ClawSweeper re-review of894480111d85fb03a5f907833e799370159af7faconfirmed the timeout finding is resolved and reported no actionable findings.Broad coverage remains with PR CI.
Scope and simplification
Against the merge base: production +73/-14 lines; tests, fixtures, and planning +257/-76; docs and guide +11/-11. The new resolver contains the Codex version lookup, cache policy, and fallback; it adds no new cache or transport owner.