Repository navigation
fix: keep ChatGPT model discovery independent of npm - #201493
Conversation
Worked on by: - @daniel-lxs Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: c129cc53-fbc7-47e1-9b45-e9767691bac5
|
🦞👀 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 replaces npm-based ChatGPT discovery version selection with the OpenClaw request-attribution version and a validated fallback. Example: ChatGPT model discovery runs with npm unavailable.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a current model-discovery failure with a focused change, sufficient Gateway proof, and no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe OpenAI plugin turns authenticated ChatGPT catalog responses into model rows published by the Gateway; this change controls the catalog request's client_version. flowchart LR
A[Runtime OpenClaw version] --> B[Provider attribution policy]
B --> C[ChatGPT catalog endpoint]
D[Selected account credential] --> C
C --> E[Authenticated model catalog]
E --> F[Gateway models list]
Technical reviewBest possible solution: Use the existing attribution owner for npm-independent discovery and preserve actionable native Codex compatibility errors. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically falls back to 0.169.0 after npm failure, and the listing contract models omission above that version; this review executed no target code. Is this the best way to solve the issue? The patch directly removes the failing dependency, reuses the existing version owner, and completes the associated cleanup without unnecessary production machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 07baab52b414. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -61, Tests -118, Docs +3. Total -176 across 16 files. Added test files: 0. 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. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 18, 2026, 6:42 PM ET / 23:42 UTC (Revision 2). |
|
Live authenticated Gateway proof for The Gateway ran with isolated state and used the access token from an existing ChatGPT sign-in as a non-refreshable credential. The OAuth endpoint was blocked, and the original sign-in file was unchanged. The Gateway was stopped and its credential copy and state were removed. The earlier full build and all 54 focused tests passed. The prerelease and |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
(cherry picked from commit 779c260) Co-authored-by: RomneyDa <[email protected]>
…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]>
…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]>
(cherry picked from commit 779c260) Release adaptation: approved 2026.11.7 models replay; see models-hook-safe-v2/REPORT.md. Co-authored-by: RomneyDa <[email protected]>
Fixes #201480
What Problem This Solves
ChatGPT model discovery depends on npm to choose the client version it reports. When that lookup fails, discovery reports the bundled Codex version, which can hide models requiring a newer client; cache misses also add an unnecessary registry request.
User Impact
User impact: ChatGPT model discovery no longer depends on npm availability or the installed Codex version. No configuration changes are needed.
Discovery can list a model that an older native Codex binary cannot run. The existing update instructions remain unchanged; this does not update Codex or change its binary selection.
Why This Change Was Made
Use the same OpenClaw version source as Responses requests. Accept calendar versions with a four-digit year from 2026 onward, preserving versioned prereleases and build metadata; use 99.0.0 when unavailable or invalid. Responses headers themselves are unchanged.
Remove the npm fetch, six-hour version cache, bundled-version floor, obsolete mocks and fixture routes, and superseded pin-equality test. Update the affected docs and test registration together.
Evidence
Reported and co-designed by @daniel-lxs, credited in the commit co-author trailer.
Work sessions
Linked for team reference; these sessions aren’t public.
Worked on by