Repository navigation
fix(openai): list ChatGPT models with the OpenClaw release version - #202380
Conversation
Co-authored-by: Daniel <[email protected]> Co-authored-by: obviyus <[email protected]>
|
🦞👀 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 lists ChatGPT subscription models using the numeric OpenClaw release version and treats empty subscription responses as failed discovery. Example: OpenClaw 2026.11.5-beta.1 refreshes a ChatGPT subscription catalog while npm is unavailable.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR removes an unnecessary discovery dependency with a focused implementation and no actionable correctness findings; current-head CI is still finishing. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe OpenAI plugin converts authenticated ChatGPT model responses into account-scoped Gateway catalog rows; the existing publication owner retains previous rows after failed discovery. flowchart TD
A[OpenClaw version attribution] --> B[OpenAI endpoint resolver]
B --> C[Authenticated ChatGPT model request]
C --> D[Plugin catalog outcome]
D --> E[Gateway catalog publication]
E --> F[Model picker and agent turns]
Technical reviewBest possible solution: Use the existing attribution version owner for subscription discovery and the existing catalog publication owner for failed-list retention. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the npm lookup and bundled-version fallback; the body reports red-on-main discovery tests, while acknowledging that no currently available model distinguishes the bundled floor from npm latest. Is this the best way to solve the issue? The patch is a small, complete cutover that removes the redundant resolver and reuses existing attribution and failure-publication contracts without adding state or configuration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a030cff0d8c3. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -55, Tests -160, Docs +1. Total -214 across 15 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. 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 Reviewed November 20, 2026, 4:22 AM ET / 09:22 UTC. |
|
Landed in 7d1d7d0.
Thanks to @daniel-lxs for the #201493 design this restores. |
… header (#202427) Follow-up to #202380. ## What Problem This Solves ChatGPT gates subscription models in two places: the `/codex/models?client_version=` listing and the `version` header on `/responses` turns. Since #202380 the listing sends the numeric OpenClaw release (`YYYY.M.P`, falling back to `99.0.0`), but OpenClaw-harness turns still send the raw runtime version. Prerelease and dev builds therefore send values the backend has never been probed with (`2026.11.5-beta.1`) or that likely fail the model gate (`unknown`, `0.0.0-dev`). Then a model can be listed but its turn rejected. On 2026-11-18, a turn with `version: 0.164.0` returned HTTP 400 for `gpt-6.2-sol`. ## Solution - Provider attribution now owns the ChatGPT gate value. For the `openai` provider, the `version` header is the numeric release (year 2026 or later), or `99.0.0`. - `User-Agent` keeps the full build (`openclaw/2026.11.5-beta.1`), so OpenAI still sees the real version. It is not a gate input. - `extensions/openai/base-url.ts` reads that header for `client_version` instead of repeating the rule, so the list and the turn send the same value by construction. - Other providers keep their headers unchanged, including xAI, which shares the OpenAI header shape. - Codex-harness turns are unchanged: the Codex binary sends its own version. ## User Impact - Stable releases: no change. `2026.11.5` was already numeric. - Beta builds: turns send `2026.11.5` instead of `2026.11.5-beta.1`. - Dev and source builds without a calendar version: turns send `99.0.0` instead of a placeholder. Turns on newly launched models then pass the same gate as the listing. ## Evidence - **Red on main, green on the fix:** `src/agents/provider-attribution.test.ts` › "sends ChatGPT the numeric OpenClaw release …". On main, 4 of 5 cases fail (`2026.11.5-beta.1`, `2026.11.5-1+build.abc`, `unknown`, `0.0.0-dev`); the plain `2026.11.5` case passes on both. Each case also checks that `User-Agent` keeps the full build. - **Consumers green:** `provider-attribution`, `agent-tools.prefix-stability`, `openai-transport-stream.base`, `stream-wrappers/openai`, `openai-codex-discovery`, `provider-live-listing.contract`, OpenAI TTS, realtime browser auth and device-code tests. - **Gates:** `tsgo:core`, `tsgo:extensions` and `check:test-types` pass. `ocx build --dts` and the packed release smoke (`scripts/release-check.ts`) pass. - **End to end** (isolated Gateway from source, fresh ChatGPT device-code login): `models.list` returned 11 subscription models with outcome `ready`, including `gpt-6.2-sol` and `gpt-6.2-astra`. A real turn on `openai/gpt-6.2-sol` returned `NVH_OK`. - **Live values:** the 2026-11-18 probe with a real ChatGPT login returned HTTP 200 on `/responses` for `gpt-6.2-sol` with `version` set to `2026.11.5` and to `99.0.0`, the only two shapes this change sends. - **Not proven live:** a beta or dev runtime version. The dev tooling strips `OPENCLAW_*` from the Gateway environment, so the source Gateway reported the stable `2026.11.5`. The attribution test covers those inputs. ## Merge Risk Two-way door: no state, config or contract changes, and a revert restores the raw header. Blast radius: the `version` header on OpenAI-provider requests (ChatGPT and platform routes) for prerelease and dev builds. Stable builds send identical headers. 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]>
… header (openclaw#202427) Follow-up to openclaw#202380. ## What Problem This Solves ChatGPT gates subscription models in two places: the `/codex/models?client_version=` listing and the `version` header on `/responses` turns. Since openclaw#202380 the listing sends the numeric OpenClaw release (`YYYY.M.P`, falling back to `99.0.0`), but OpenClaw-harness turns still send the raw runtime version. Prerelease and dev builds therefore send values the backend has never been probed with (`2026.11.5-beta.1`) or that likely fail the model gate (`unknown`, `0.0.0-dev`). Then a model can be listed but its turn rejected. On 2026-11-18, a turn with `version: 0.164.0` returned HTTP 400 for `gpt-6.2-sol`. ## Solution - Provider attribution now owns the ChatGPT gate value. For the `openai` provider, the `version` header is the numeric release (year 2026 or later), or `99.0.0`. - `User-Agent` keeps the full build (`openclaw/2026.11.5-beta.1`), so OpenAI still sees the real version. It is not a gate input. - `extensions/openai/base-url.ts` reads that header for `client_version` instead of repeating the rule, so the list and the turn send the same value by construction. - Other providers keep their headers unchanged, including xAI, which shares the OpenAI header shape. - Codex-harness turns are unchanged: the Codex binary sends its own version. ## User Impact - Stable releases: no change. `2026.11.5` was already numeric. - Beta builds: turns send `2026.11.5` instead of `2026.11.5-beta.1`. - Dev and source builds without a calendar version: turns send `99.0.0` instead of a placeholder. Turns on newly launched models then pass the same gate as the listing. ## Evidence - **Red on main, green on the fix:** `src/agents/provider-attribution.test.ts` › "sends ChatGPT the numeric OpenClaw release …". On main, 4 of 5 cases fail (`2026.11.5-beta.1`, `2026.11.5-1+build.abc`, `unknown`, `0.0.0-dev`); the plain `2026.11.5` case passes on both. Each case also checks that `User-Agent` keeps the full build. - **Consumers green:** `provider-attribution`, `agent-tools.prefix-stability`, `openai-transport-stream.base`, `stream-wrappers/openai`, `openai-codex-discovery`, `provider-live-listing.contract`, OpenAI TTS, realtime browser auth and device-code tests. - **Gates:** `tsgo:core`, `tsgo:extensions` and `check:test-types` pass. `ocx build --dts` and the packed release smoke (`scripts/release-check.ts`) pass. - **End to end** (isolated Gateway from source, fresh ChatGPT device-code login): `models.list` returned 11 subscription models with outcome `ready`, including `gpt-6.2-sol` and `gpt-6.2-astra`. A real turn on `openai/gpt-6.2-sol` returned `NVH_OK`. - **Live values:** the 2026-11-18 probe with a real ChatGPT login returned HTTP 200 on `/responses` for `gpt-6.2-sol` with `version` set to `2026.11.5` and to `99.0.0`, the only two shapes this change sends. - **Not proven live:** a beta or dev runtime version. The dev tooling strips `OPENCLAW_*` from the Gateway environment, so the source Gateway reported the stable `2026.11.5`. The attribution test covers those inputs. ## Merge Risk Two-way door: no state, config or contract changes, and a revert restores the raw header. Blast radius: the `version` header on OpenAI-provider requests (ChatGPT and platform routes) for prerelease and dev builds. Stable builds send identical headers. Co-authored-by: Ayaan Zaidi <[email protected]>
… header (#202427) Follow-up to #202380. ChatGPT gates subscription models in two places: the `/codex/models?client_version=` listing and the `version` header on `/responses` turns. Since #202380 the listing sends the numeric OpenClaw release (`YYYY.M.P`, falling back to `99.0.0`), but OpenClaw-harness turns still send the raw runtime version. Prerelease and dev builds therefore send values the backend has never been probed with (`2026.11.5-beta.1`) or that likely fail the model gate (`unknown`, `0.0.0-dev`). Then a model can be listed but its turn rejected. On 2026-11-18, a turn with `version: 0.164.0` returned HTTP 400 for `gpt-6.2-sol`. - Provider attribution now owns the ChatGPT gate value. For the `openai` provider, the `version` header is the numeric release (year 2026 or later), or `99.0.0`. - `User-Agent` keeps the full build (`openclaw/2026.11.5-beta.1`), so OpenAI still sees the real version. It is not a gate input. - `extensions/openai/base-url.ts` reads that header for `client_version` instead of repeating the rule, so the list and the turn send the same value by construction. - Other providers keep their headers unchanged, including xAI, which shares the OpenAI header shape. - Codex-harness turns are unchanged: the Codex binary sends its own version. - Stable releases: no change. `2026.11.5` was already numeric. - Beta builds: turns send `2026.11.5` instead of `2026.11.5-beta.1`. - Dev and source builds without a calendar version: turns send `99.0.0` instead of a placeholder. Turns on newly launched models then pass the same gate as the listing. - **Red on main, green on the fix:** `src/agents/provider-attribution.test.ts` › "sends ChatGPT the numeric OpenClaw release …". On main, 4 of 5 cases fail (`2026.11.5-beta.1`, `2026.11.5-1+build.abc`, `unknown`, `0.0.0-dev`); the plain `2026.11.5` case passes on both. Each case also checks that `User-Agent` keeps the full build. - **Consumers green:** `provider-attribution`, `agent-tools.prefix-stability`, `openai-transport-stream.base`, `stream-wrappers/openai`, `openai-codex-discovery`, `provider-live-listing.contract`, OpenAI TTS, realtime browser auth and device-code tests. - **Gates:** `tsgo:core`, `tsgo:extensions` and `check:test-types` pass. `ocx build --dts` and the packed release smoke (`scripts/release-check.ts`) pass. - **End to end** (isolated Gateway from source, fresh ChatGPT device-code login): `models.list` returned 11 subscription models with outcome `ready`, including `gpt-6.2-sol` and `gpt-6.2-astra`. A real turn on `openai/gpt-6.2-sol` returned `NVH_OK`. - **Live values:** the 2026-11-18 probe with a real ChatGPT login returned HTTP 200 on `/responses` for `gpt-6.2-sol` with `version` set to `2026.11.5` and to `99.0.0`, the only two shapes this change sends. - **Not proven live:** a beta or dev runtime version. The dev tooling strips `OPENCLAW_*` from the Gateway environment, so the source Gateway reported the stable `2026.11.5`. The attribution test covers those inputs. Two-way door: no state, config or contract changes, and a revert restores the raw header. Blast radius: the `version` header on OpenAI-provider requests (ChatGPT and platform routes) for prerelease and dev builds. Stable builds send identical headers. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit e4c17c5) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 0269488deb840641bce094c2d300bb0816ac3ab1) (cherry picked from commit 412b23ea0b62464ec3180fcd9d1ad094f5439dd5)
…02427) Use provider attribution as the single numeric calendar-version owner while preserving the complete runtime version in User-Agent and xAI headers. Release adaptation: preserve the baseline's full-string invalid-version fallback; update its existing discovery table for numeric beta/build versions. The upstream parser accepted an otherwise invalid suffix. No dependencies, configuration, schema, or native Codex behavior change. The five-input header regression fails four cases before the production fix. Retain the existing invalid-version discovery cases and transport/prefix checks. The 26 test lines exercise previously untested prerelease/development headers. Companion audit: no later source-path fixes at pinned 96304dd. The preceding openclaw#202380 numeric-listing prerequisite is subsumed by the baseline's existing release-validation/listing helper and this single-owner cutover. (cherry picked from commit e4c17c5) Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 605ad3b6381e3897383d487ec218a493438a7389) (cherry picked from commit fab91bd61333d998ec941c9d77d14d49b9a67e2f)
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 whoseminimal_client_versionis above X. On main (#202284), X comes from a lookup of the latest@openai/codexon 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
versionheader (provider attribution). The list and the turn use one value from one owner.YYYY.M.Ppart (year 2026 or later). For example,2026.11.5-beta.1lists as2026.11.5. Anything else (unknown,0.0.0-dev, a badOPENCLAW_VERSIONoverride, or a proxy without attribution headers) lists as99.0.0.versionheader unchanged. Keep Codex binary selection and update behavior unchanged.Why this replaces the earlier designs:
99.0.0, Zed0.999.0, Crush999.0.0.Accepted edge cases (code comment in
base-url.ts):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
/modelscall.Evidence
extensions/openai/openai-codex-discovery.test.ts):/models). The fix makes exactly one, to chatgpt.com, with the expectedclient_version.expected ['ready'] to deeply equal ['unavailable']) and passes on the fix.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.client_version2026.11.5, 0.166.0, 0.169.0 and 99.0.0 return the same 13 models, includinggpt-6.2-solandgpt-6.2-astra(minimal_client_version0.166.0)./responseswithversion: 2026.11.5ongpt-6.2-solreturns 200.models.listreturned 11 subscription models with outcomeready, includinggpt-6.2-sol(1.05M context) andgpt-6.2-astra.registry.npmjs.orgrequest.openai/gpt-6.2-solreturnedCXV_OK2.OPENCLAW_VERSION=unknown(the dev tooling stripsOPENCLAW_*). 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.