Skip to content

Let Codex use newly available account models before catalog refresh - #127394

Merged
pash-openai merged 4 commits into
mainfrom
pash/codex-native-future-models
Aug 21, 2026
Merged

pash-openai merged 4 commits into
mainfrom
pash/codex-native-future-models

Conversation

@pash-openai

Copy link
Copy Markdown
Contributor

Codex can expose a new model through its own account before OpenClaw has refreshed its provider catalog. Today that request can fail three times: the early harness probe runs before auth is prepared, the provider rejects an unfamiliar model, and a single native route incorrectly demands a host credential. This change lets an explicitly selected Codex runtime own model discovery and authentication in that narrow case while preserving authored endpoints, explicit credentials, incompatible routes, and configured reasoning options.

@pash-openai
pash-openai requested a review from a team as a code owner August 21, 2026 18:59
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 21, 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-08-21T19:02:46.285552Z 30dba81 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 the maintainer Maintainer-authored PR label Aug 21, 2026
@pash-openai
pash-openai enabled auto-merge (squash) August 21, 2026 19:00
@pash-openai
pash-openai force-pushed the pash/codex-native-future-models branch from 30dba81 to 62098d3 Compare August 21, 2026 19:08
@pash-openai
pash-openai merged commit 4573635 into main Aug 21, 2026
398 of 400 checks passed
@pash-openai
pash-openai deleted the pash/codex-native-future-models branch August 21, 2026 19:30
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
…penclaw#127394)

* Let Codex run newly available account models without host credentials

* Keep authored provider routes ahead of native account authentication

* Keep native Codex account discovery consistent with model availability

* Preserve advanced reasoning for newly discovered Codex models
obviyus added a commit that referenced this pull request Oct 1, 2026
…PI-key users (#162563)

## What Problem This Solves

Fixes: with an OpenAI API key, chat models that the account's `/v1/models` lists but the bundled manifest doesn't (for example `gpt-5.2`, `gpt-4.1`, `o3`) are missing from `/models`. Selecting one fails with `Unknown model: openai/gpt-5.2`.

## User Impact

API-key users can pick and run current GPT and o-series chat models that their account exposes, including future ids that ship before a manifest update. Manifest models keep their existing rows and prices. Admitted models report cost as unknown: the cost is omitted, not shown as `$0`. Media, realtime, search, embedding, legacy, dated-snapshot, fine-tune and experiment ids stay hidden.

## Why This Change Was Made

#114258 intersects the manifest with the account's live catalog so OpenClaw advertises only models the account can use, and manifest metadata wins. This change keeps that intersection. It also admits live ids that match current chat families (`gpt-4o`, `gpt-4.1`, `gpt-5`+, `o1`+) and are neither known route ids nor manifest rows.

Admitted rows are deliberately conservative: Responses API, text-only input, 128k context, 16,384 max output tokens, and reasoning only for GPT-5+ and o-series. Their cost uses the existing zero placeholder. Shared usage reporting already treats zero catalog rates as unknown pricing, so it omits the cost instead of reporting `$0`.

Some families appear in `/v1/models` but return 404 on `/v1/responses` for the same key: every `*-chat-latest` and `*-cyber` id, and all `*-codex` ids except `gpt-5.3-codex`. They are excluded, along with `preview`, `alpha` and `beta` variants. The admission rules now live in a new `account-models.ts`, and the API-key catalog tests moved to `openai-api-key-catalog.test.ts`. The provider module and its test file stay within their line-count caps.

## Evidence

- Regression test `admits account chat models missing from the manifest with conservative metadata` fails on `main` (`expected [ 'gpt-5.5' ]`) and passes on this branch. It covers admitted rows (`gpt-4.1-mini`, a future `gpt-6.2`, `o3`), conservative metadata, the zero cost placeholder, manifest precedence, and 25 excluded ids (snapshot, chat-latest, codex, cyber, preview/alpha/beta, search, audio, realtime, image, embedding, moderation, fine-tune, experiment).
- Live before/after with the same real API key against two isolated Gateways built from `main` (`d0f06ee`) and this branch:
  - The account's `/v1/models` lists 169 ids. `models.list` showed 16 OpenAI rows on `main` and 34 on the branch. The 18 added ids are `gpt-4.1`, `gpt-4.1-mini`, `gpt-4.1-nano`, `gpt-4o`, `gpt-4o-mini`, `gpt-5`, `gpt-5-mini`, `gpt-5-nano`, `gpt-5-pro`, `gpt-5.1`, `gpt-5.2`, `gpt-5.2-pro`, `o1`, `o1-pro`, `o3`, `o3-mini`, `o3-pro` and `o4-mini`. Each one returned 200 from a direct `/v1/responses` probe. The picker gained no non-chat ids. All 16 manifest rows, including `gpt-6.1-sol` from #161400, are identical on both builds.
  - Running a turn on `openai/gpt-5.2`: `main` fails with `Unknown model: openai/gpt-5.2`. The branch replies `ok`. The run reports usage (20k input / 5 output tokens) with no `costUsd`, and `/status` shows tokens but no Cost row.
  - `openai/gpt-6.1-sol` (manifest-owned) works the same on both builds, with priced cost (`$0.0028` on `main`, `$0.0025` on the branch).
- `pnpm test extensions/openai/openai-provider.test.ts extensions/openai/openai-api-key-catalog.test.ts`: 70 passed. `pnpm check:changed` passed.
- Test cost: the only new test is the regression; the other nine API-key catalog tests moved unchanged out of `openai-provider.test.ts`. Local `pnpm test <file> --maxWorkers=1` wall time is 25.0s for `openai-api-key-catalog.test.ts` (10 tests) and 23.8s for `openai-provider.test.ts` (60 tests), mostly transform. In CI run [36839484116](https://github.com/openclaw/openclaw/actions/runs/36839484116), test time sums to 2.07s and 12.8s; the new regression takes 3ms.
- No overlap with Pash/Sarah changes: #127394 touches only the ChatGPT/Codex discovery path and shared test fixtures.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…PI-key users (openclaw#162563)

## What Problem This Solves

Fixes: with an OpenAI API key, chat models that the account's `/v1/models` lists but the bundled manifest doesn't (for example `gpt-5.2`, `gpt-4.1`, `o3`) are missing from `/models`. Selecting one fails with `Unknown model: openai/gpt-5.2`.

## User Impact

API-key users can pick and run current GPT and o-series chat models that their account exposes, including future ids that ship before a manifest update. Manifest models keep their existing rows and prices. Admitted models report cost as unknown: the cost is omitted, not shown as `$0`. Media, realtime, search, embedding, legacy, dated-snapshot, fine-tune and experiment ids stay hidden.

## Why This Change Was Made

openclaw#114258 intersects the manifest with the account's live catalog so OpenClaw advertises only models the account can use, and manifest metadata wins. This change keeps that intersection. It also admits live ids that match current chat families (`gpt-4o`, `gpt-4.1`, `gpt-5`+, `o1`+) and are neither known route ids nor manifest rows.

Admitted rows are deliberately conservative: Responses API, text-only input, 128k context, 16,384 max output tokens, and reasoning only for GPT-5+ and o-series. Their cost uses the existing zero placeholder. Shared usage reporting already treats zero catalog rates as unknown pricing, so it omits the cost instead of reporting `$0`.

Some families appear in `/v1/models` but return 404 on `/v1/responses` for the same key: every `*-chat-latest` and `*-cyber` id, and all `*-codex` ids except `gpt-5.3-codex`. They are excluded, along with `preview`, `alpha` and `beta` variants. The admission rules now live in a new `account-models.ts`, and the API-key catalog tests moved to `openai-api-key-catalog.test.ts`. The provider module and its test file stay within their line-count caps.

## Evidence

- Regression test `admits account chat models missing from the manifest with conservative metadata` fails on `main` (`expected [ 'gpt-5.5' ]`) and passes on this branch. It covers admitted rows (`gpt-4.1-mini`, a future `gpt-6.2`, `o3`), conservative metadata, the zero cost placeholder, manifest precedence, and 25 excluded ids (snapshot, chat-latest, codex, cyber, preview/alpha/beta, search, audio, realtime, image, embedding, moderation, fine-tune, experiment).
- Live before/after with the same real API key against two isolated Gateways built from `main` (`dd8d9f0`) and this branch:
  - The account's `/v1/models` lists 169 ids. `models.list` showed 16 OpenAI rows on `main` and 34 on the branch. The 18 added ids are `gpt-4.1`, `gpt-4.1-mini`, `gpt-4.1-nano`, `gpt-4o`, `gpt-4o-mini`, `gpt-5`, `gpt-5-mini`, `gpt-5-nano`, `gpt-5-pro`, `gpt-5.1`, `gpt-5.2`, `gpt-5.2-pro`, `o1`, `o1-pro`, `o3`, `o3-mini`, `o3-pro` and `o4-mini`. Each one returned 200 from a direct `/v1/responses` probe. The picker gained no non-chat ids. All 16 manifest rows, including `gpt-6.1-sol` from openclaw#161400, are identical on both builds.
  - Running a turn on `openai/gpt-5.2`: `main` fails with `Unknown model: openai/gpt-5.2`. The branch replies `ok`. The run reports usage (20k input / 5 output tokens) with no `costUsd`, and `/status` shows tokens but no Cost row.
  - `openai/gpt-6.1-sol` (manifest-owned) works the same on both builds, with priced cost (`$0.0028` on `main`, `$0.0025` on the branch).
- `pnpm test extensions/openai/openai-provider.test.ts extensions/openai/openai-api-key-catalog.test.ts`: 70 passed. `pnpm check:changed` passed.
- Test cost: the only new test is the regression; the other nine API-key catalog tests moved unchanged out of `openai-provider.test.ts`. Local `pnpm test <file> --maxWorkers=1` wall time is 25.0s for `openai-api-key-catalog.test.ts` (10 tests) and 23.8s for `openai-provider.test.ts` (60 tests), mostly transform. In CI run [36839484116](https://github.com/openclaw/openclaw/actions/runs/36839484116), test time sums to 2.07s and 12.8s; the new regression takes 3ms.
- No overlap with Pash/Sarah changes: openclaw#127394 touches only the ChatGPT/Codex discovery path and shared test fixtures.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Oct 8, 2026
…elease (#167387)

Related: #157920

## What Problem This Solves

Fixes: new ChatGPT-login models stay hidden from `/models` until an OpenClaw release, because model discovery reports a hard-coded Codex client version.

## User Impact

User impact: with ChatGPT login, models that need a newer Codex client appear in the model list once that Codex version is published to npm, with no OpenClaw release.

Example: 2026.9.8 reports `client_version=0.158.0`, so the ChatGPT backend hides `gpt-6.1-sol`. With this change, OpenClaw reports `0.161.0` (current npm `latest`) and the model appears.

## Why This Change Was Made

ChatGPT model discovery now asks npm for `@openai/codex`'s `latest` stable version and sends it as `client_version`.

- One small request to `registry.npmjs.org`, through the SSRF guard, with a 5 s timeout.
- The version is cached for 6 hours. Concurrent discoveries share one request.
- If npm is unreachable or returns something odd, OpenClaw keeps the last version it got from npm, or the bundled pin (`0.160.0`, unchanged contract test) if it never got one, and retries after 5 minutes.
- If the model-list request itself fails, the previous list stays (existing catalog retention for failed providers).
- Only stable versions are used. If OpenClaw pins a newer prerelease, the pin wins.
- This changes only the version OpenClaw *reports* for discovery. The bundled Codex binary and the Codex harness are unchanged.

Tradeoff: #113615 aligned this value with the bundled Codex pin. Reporting a newer version can list a model whose protocol the current build does not handle yet; that model then fails on its first turn instead of being hidden. We chose visible-and-explainable over silently missing. This is the same tradeoff Hermes makes (it reports `99.0.0`); a real published version is more honest and avoids out-of-sequence version handling on the backend.

## Evidence

**Backend behavior (real ChatGPT account, token kept in the browser):** visible models by `client_version`:

| `client_version` | `gpt-6.1-sol` listed |
|---|---|
| `0.158.0` (2026.9.8 pin) | no |
| `0.160.0` (current pin) | yes |
| `0.161.0` (npm `latest`) | yes |

**Real CLI flow** (`pnpm openclaw --profile <isolated> models list --provider openai --refresh --plain`, ChatGPT OAuth profile). To make the run discriminating, the fallback pin was temporarily set to `0.158.0` in a throwaway edit (reverted):

- npm reachable → `openai/gpt-6.1-sol` listed (npm `latest` 0.161.0 wins over the old pin).
- npm lookup forced to fail → `openai/gpt-6.1-sol` missing (falls back to the old pin).

**Real npm lookup through the guarded fetch:** first call returned `.../models?client_version=0.161.0` in 356 ms; the second call hit the cache in 0 ms.

**Tests:** new unit tests cover the npm version, cache reuse and expiry, shared in-flight request, fallback on HTTP error / prerelease / older-than-pin, keeping the last npm version when a later refresh fails, and the 5-minute failure retry. Existing OpenAI discovery tests pass with the resolver isolated. `node scripts/check-changed.mjs` passes.

No overlap with Pash/Sarah changes: `4573635c77f` (#127394) touches `openai-provider.test.ts` for account-model routing, not discovery versioning.

**Merge danger:** two-way door. No stored state, config, or schema change; a revert restores the pinned version. Blast radius: ChatGPT-login model discovery only. Worst case, a model that the current build cannot drive appears in the list and fails on its first turn.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…elease (openclaw#167387)

Related: openclaw#157920

## What Problem This Solves

Fixes: new ChatGPT-login models stay hidden from `/models` until an OpenClaw release, because model discovery reports a hard-coded Codex client version.

## User Impact

User impact: with ChatGPT login, models that need a newer Codex client appear in the model list once that Codex version is published to npm, with no OpenClaw release.

Example: 2026.9.8 reports `client_version=0.158.0`, so the ChatGPT backend hides `gpt-6.1-sol`. With this change, OpenClaw reports `0.161.0` (current npm `latest`) and the model appears.

## Why This Change Was Made

ChatGPT model discovery now asks npm for `@openai/codex`'s `latest` stable version and sends it as `client_version`.

- One small request to `registry.npmjs.org`, through the SSRF guard, with a 5 s timeout.
- The version is cached for 6 hours. Concurrent discoveries share one request.
- If npm is unreachable or returns something odd, OpenClaw keeps the last version it got from npm, or the bundled pin (`0.160.0`, unchanged contract test) if it never got one, and retries after 5 minutes.
- If the model-list request itself fails, the previous list stays (existing catalog retention for failed providers).
- Only stable versions are used. If OpenClaw pins a newer prerelease, the pin wins.
- This changes only the version OpenClaw *reports* for discovery. The bundled Codex binary and the Codex harness are unchanged.

Tradeoff: openclaw#113615 aligned this value with the bundled Codex pin. Reporting a newer version can list a model whose protocol the current build does not handle yet; that model then fails on its first turn instead of being hidden. We chose visible-and-explainable over silently missing. This is the same tradeoff Hermes makes (it reports `99.0.0`); a real published version is more honest and avoids out-of-sequence version handling on the backend.

## Evidence

**Backend behavior (real ChatGPT account, token kept in the browser):** visible models by `client_version`:

| `client_version` | `gpt-6.1-sol` listed |
|---|---|
| `0.158.0` (2026.9.8 pin) | no |
| `0.160.0` (current pin) | yes |
| `0.161.0` (npm `latest`) | yes |

**Real CLI flow** (`pnpm openclaw --profile <isolated> models list --provider openai --refresh --plain`, ChatGPT OAuth profile). To make the run discriminating, the fallback pin was temporarily set to `0.158.0` in a throwaway edit (reverted):

- npm reachable → `openai/gpt-6.1-sol` listed (npm `latest` 0.161.0 wins over the old pin).
- npm lookup forced to fail → `openai/gpt-6.1-sol` missing (falls back to the old pin).

**Real npm lookup through the guarded fetch:** first call returned `.../models?client_version=0.161.0` in 356 ms; the second call hit the cache in 0 ms.

**Tests:** new unit tests cover the npm version, cache reuse and expiry, shared in-flight request, fallback on HTTP error / prerelease / older-than-pin, keeping the last npm version when a later refresh fails, and the 5-minute failure retry. Existing OpenAI discovery tests pass with the resolver isolated. `node scripts/check-changed.mjs` passes.

No overlap with Pash/Sarah changes: `a9c35f3d0f6` (openclaw#127394) touches `openai-provider.test.ts` for account-model routing, not discovery versioning.

**Merge danger:** two-way door. No stored state, config, or schema change; a revert restores the pinned version. Blast radius: ChatGPT-login model discovery only. Worst case, a model that the current build cannot drive appears in the list and fails on its first turn.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant