Skip to content

fix(openai): show account chat models missing from the manifest for API-key users - #162563

Merged
obviyus merged 1 commit into
mainfrom
fix/openai-api-key-new-models
Oct 1, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/openai-api-key-new-models

Conversation

@obviyus

@obviyus obviyus commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

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 feat(openai): support GPT-6.1 Sol #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, test time sums to 2.07s and 12.8s; the new regression takes 3ms.
  • Related history: Let Codex use newly available account models before catalog refresh #127394 touches only the ChatGPT/Codex discovery path and shared test fixtures.

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 5:12 AM ET / 09:12 UTC (Revision 2).

ClawSweeper review

What this changes

The OpenAI plugin adds conservative catalog entries for account-listed chat models missing from its manifest and moves API-key discovery tests into a dedicated suite.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still omits account-listed chat models absent from the manifest. The earlier test-cost request is satisfied, the supplied live evidence covers the repaired behavior, and no actionable introduced defect was found.

Priority: P2
Reviewed head: 46a49ecef23405f5b34ea5c6939e22c9faf5d421

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with convincing live before-and-after evidence, meaningful regression coverage, and the earlier evidence request resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured live observations exercise the changed Platform catalog owner through isolated Gateway models.list and a real gpt-5.2 agent turn, showing added usable models, an after-fix reply, preserved manifest rows, and omitted unknown cost. Existing model-definition formats and stored-state contracts remain unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured live observations exercise the changed Platform catalog owner through isolated Gateway models.list and a real gpt-5.2 agent turn, showing added usable models, an after-fix reply, preserved manifest rows, and omitted unknown cost. Existing model-definition formats and stored-state contracts remain unchanged.
Evidence reviewed 8 items Verified introduced change: The pinned merge-base-to-head diff adds account-only model projection and invokes it after filtering existing catalog rows; existing rows retain precedence.
Still necessary on current main: Fetched main builds the API-key catalog by intersecting account IDs with manifest rows and the existing chat-latest row; it has no account-only chat projection.
Latest release comparison: The provider source at the supplied latest-release commit also uses the manifest intersection. Local release-blob inspection failed with a promisor-fetch HTTP 403; the exact release source was successfully inspected through GitHub’s contents API.
Findings None None.
Security None None.

How this fits together

The OpenAI plugin combines account model discovery with bundled model metadata to populate OpenClaw’s model catalog. That catalog feeds model pickers and agent model resolution.

flowchart TD
  A[Selected API key] --> B[Account model discovery]
  B --> C[Account model IDs]
  D[Bundled model metadata] --> E[Catalog selection]
  C --> E
  E --> F[Known rows and conservative chat rows]
  F --> G[Model picker and agent execution]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +49, Tests +120. Total +169 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 74 25 +49
Tests 2 365 245 +120
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 439 270 +169

Review metrics

Metric Value Why it matters
Production versus test growth production +49 net lines; tests +120 net lines Production growth supplies the missing account-only projection; test growth retains migrated coverage and adds one catalog-boundary regression.
Added regression cost 1 new regression; 3ms reported CI test time The requested timing evidence is now present, and the remaining catalog cases are migrated coverage.

Technical review

Best possible solution:

Keep account discovery in the OpenAI plugin, preserve authored and manifest metadata, and supply conservative metadata only for otherwise undescribed account-visible chat models.

Do we have a high-confidence way to reproduce the issue?

Yes: current-main source deterministically excludes an account-listed chat ID absent from the manifest. The contributor also records a real before-and-after gpt-5.2 agent turn; this read-only review did not execute target code.

Is this the best way to solve the issue?

Yes: the patch repairs the existing provider-owned catalog path while preserving known metadata, account filtering, and fallback behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3bbf4c8ebab3.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs model discovery and selection for API-key accounts with chat models missing from the bundled manifest.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured live observations exercise the changed Platform catalog owner through isolated Gateway models.list and a real gpt-5.2 agent turn, showing added usable models, an after-fix reply, preserved manifest rows, and omitted unknown cost. Existing model-definition formats and stored-state contracts remain unchanged.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured live observations exercise the changed Platform catalog owner through isolated Gateway models.list and a real gpt-5.2 agent turn, showing added usable models, an after-fix reply, preserved manifest rows, and omitted unknown cost. Existing model-definition formats and stored-state contracts remain unchanged.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff adds account-only model projection and invokes it after filtering existing catalog rows; existing rows retain precedence. (extensions/openai/openai-provider.ts:248, 46a49ecef234)
  • Still necessary on current main: Fetched main builds the API-key catalog by intersecting account IDs with manifest rows and the existing chat-latest row; it has no account-only chat projection. (extensions/openai/openai-provider.ts:222, 3bbf4c8ebab3)
  • Latest release comparison: The provider source at the supplied latest-release commit also uses the manifest intersection. Local release-blob inspection failed with a promisor-fetch HTTP 403; the exact release source was successfully inspected through GitHub’s contents API. (extensions/openai/openai-provider.ts, c074824a27c9)
  • Scoped admission and compatibility: The new helper excludes known route IDs, preserves catalog-owned metadata, filters non-chat and experimental families, and emits ordinary existing model-definition shapes. Auth selection, custom endpoints, rejected-key handling, and outage fallback remain unchanged; no stored format or public plugin API changes. (extensions/openai/account-models.ts:26, 46a49ecef234)
  • Real before-and-after behavior: The captured PR body, sourceRevision b10aaa1579886eaf61bb24298a97f4f4258176ff1762941ed415d96a5ce42ea6, records two isolated Gateways using the same real API key: 16 versus 34 catalog rows, successful Responses probes for all 18 additions, and a gpt-5.2 agent turn changing from Unknown model to an ok reply. Usage omitted unknown cost, while all 16 manifest rows stayed identical and a priced manifest model remained usable. (46a49ecef234)
  • Previous review request resolved: The sole retained prior rank-up request was measured test cost. The captured body now reports 25.0s and 23.8s local per-file wall time, 2.07s and 12.8s CI test time, and 3ms for the new regression; the author subsequently requested re-review. The regression exercises the registered provider catalog boundary, while the existing API-key cases move into the new suite. (extensions/openai/openai-api-key-catalog.test.ts:178, 46a49ecef234)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • stevenlee-oai: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-01T09:01:20.109Z sha 46a49ec :: needs changes before merge. :: none

@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus merged commit c1f5fbe into main Oct 1, 2026
117 checks passed
@obviyus
obviyus deleted the fix/openai-api-key-new-models branch October 1, 2026 09:13
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in c1f5fbe.

Bug: with an OpenAI API key, chat models that the account's /v1/models lists but the manifest doesn't (gpt-5.2, gpt-4.1, o3, …) were missing from /models, and selecting one failed with Unknown model.

Fix: the account-intersected catalog (#114258) now also admits current GPT and o-series chat ids. Their rows are conservative and their cost is unknown, so it's omitted rather than shown as ``. Manifest rows still win. Non-chat ids stay hidden, as do the chat-latest/codex/cyber/preview families, which are listed but return 404 on /v1/responses.

Proof: the regression test fails on main and passes here. Live isolated Gateways using the same real key showed 16 → 34 OpenAI picker rows, every added id served by /v1/responses, and 0 non-chat ids. A gpt-5.2 turn succeeds with no cost reported; main returns Unknown model. gpt-6.1-sol behaves the same as before, with priced cost.

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 9, 2026
## What Problem This Solves

Fixes: when you sign in to OpenAI with an API key, or to xAI or any provider that uses the shared live model listing, chat models the provider lists stay hidden from the model pickers until an OpenClaw release adds them.

## User Impact

User impact: signed-in users see every chat model their provider lists, including models released after their OpenClaw version. Catalog rows still supply names, prices and context limits for models OpenClaw already knows. Embedding, image, video, audio, realtime, speech, transcription, moderation, legacy-completions and retired models stay hidden.

On the OpenAI API-key listing, pre-GPT-5 families (GPT-3.5, GPT-4, GPT-4o, GPT-4.1, o1, o3, o4, and fine-tunes of them) are now hidden from `models list` and the pickers, including the 11 such rows `main` shows today. Ayaan chose this over changing the default runtime: these models fail on the default runtime, so listing them offers a choice that breaks on the first turn. GPT-5+ and IDs OpenClaw does not recognize keep appearing without a release.

Existing setups keep working: a pre-GPT-5 model named as the default model, an `agents.defaults.models` key, an allowlist entry or a session model override still resolves, with the same conservative metadata the listing used to give it. To use one, reference it and pin the OpenClaw runtime:

```json5
{
  agents: {
    defaults: {
      model: { primary: "openai/gpt-4o" },
      models: { "openai/gpt-4o": { agentRuntime: { id: "openclaw" } } },
    },
  },
}
```

## Why This Change Was Made

- **Shared listing.** `buildLiveModelProviderConfig` without `projectRows` used to keep only the static rows whose IDs were listed. It now runs listed rows through the existing shared chat classifier, the same one that `liveModelDiscovery` already uses. Static rows describe matching IDs, and other chat IDs get conservative rows. The plugin's `readModelId` selector still runs first (default: `id` on `object: "model"` rows, as on `main`): the ID it returns names the row, and a row it rejects stays out. Strict and advisory failure handling is unchanged: a failed listing keeps the fallback rows, and a successful empty listing stays empty. The direct consumer is the xAI API-key catalog. Third-party plugins that call this helper without `projectRows` get the same behavior; `docs/plugins/sdk-provider-plugins/model-catalogs.md` now describes this default and how `readModelId` restricts it.
- **Classifier.** The classifier also excludes realtime, audio, bare `image`/`video` IDs and legacy completions models (`babbage`, `davinci`, `gpt-3.5-turbo-instruct`), plus rows whose `shutdown_date` has passed. On the real OpenAI listing, all 25 rows with a past shutdown date fail on `/v1/responses` (22 × 404, 3 × 400). Exclusions also apply to IDs in the static catalog. `<modality>-text-to-text` kinds (Hugging Face vision/audio chat models) stay admitted.
- **OpenAI API key.** The catalog now uses the same shared builder. This removes the GPT-4o/4.1/5+/o family allowlist and the broad deny list from #162563. OpenClaw sends API-key turns through the Responses API, so narrow, named exclusions remain:
  - Pre-GPT-5 families (`^(?:ft:)?(?:gpt-3\.5|gpt-4|o[134])`): on the default runtime the Codex harness rejects every one of them with `400 Invalid value: 'custom'`, and 13 of them (gpt-3.5, gpt-4, gpt-4-turbo, gpt-4.1-nano, o1, o3-mini and snapshots) also reject hosted web search on the OpenClaw runtime. The rule also applies to catalog rows; the OpenAI manifest has none of these families (on `main` they came only from #162563's allowlist). Hiding only affects browsing: the OpenAI provider's `resolveDynamicModel` hook, which core calls only for a specific selected ref, returns the same conservative row for these IDs, so config defaults, allowlist entries and session overrides still resolve.
  - `search` models: Chat Completions only, per the [official model page](https://developers.openai.com/api/docs/models/gpt-4o-search-preview). On our key, `/v1/responses` returned 400 "not supported with the Responses API".
  - `live`, `cyber`, experiment (`exp`) and `alpha` codename IDs: our key lists them, but `/v1/responses` returns 404 or a persistent 500 for them.
  - Subscription-only route IDs (`gpt-5.3-codex-spark`) stay hidden, so the platform and ChatGPT routes stay separate.

  OpenAI IDs without a catalog row keep the existing conservative metadata from #162563 (Responses, text input, 128k context, 16,384 max output, reasoning for GPT-5+ and o-series, unknown cost). The shared prefix template is not used for OpenAI: every OpenAI ID starts with `gpt-`, so an unknown ID would inherit GPT-5 reasoning settings from an unrelated row.
- **xAI.** Multi-agent models stay hidden: they reject the client-side tools that every OpenClaw turn sends (documented xAI limitation).
- Retained gates: Anthropic `acceptUnknownModel`, OpenAI OAuth visibility, xAI OAuth backend eligibility, Google, Bedrock, Copilot, routed providers, replace mode and allowlists are unchanged.

## Evidence

**Regression tests (each fails on `main`, passes here):**
- `src/plugin-sdk/provider-catalog-live-runtime.test.ts`: a listed unknown chat ID shows. Realtime, audio, image, video, legacy-completions and past-shutdown rows stay out, including a static ID with image-only output. A Hugging Face `image-text-to-text` row stays. A failed listing keeps the static rows. The existing strict test still covers authoritative empty and failure.
- `src/plugin-sdk/provider-catalog-live-runtime.test.ts` (selector): a strict plugin whose selector reads `slug` keeps static `model-a`, admits an unknown `fresh-chat` slug, drops a `fresh-embedding` slug, and keeps out an ordinary `{ id: "model-b", object: "model" }` row the selector rejects. On `ceaccc6` it fails (received only `model-b`); on this head it passes.
- `extensions/openai/openai-api-key-catalog.test.ts`: dated snapshots, `gpt-5.3-codex` and a future `gpt-6.2` show with conservative metadata. `gpt-4-0613`, `gpt-4.1-mini`, `o3` and an `ft:gpt-4.1-mini:...` fine-tune stay hidden, as do search, live, cyber, experiment, alpha, subscription-only, non-chat and retired IDs. Without the pre-GPT-5 rule the test fails (1 failed, 6 passed); with it, 7/7 pass. A listing with only non-chat IDs is authoritative-empty.
- `extensions/xai/index.test.ts`: an unknown `grok-5-preview` shows. Multi-agent and `grok-imagine-*` stay hidden.
- `extensions/openai/openai-dynamic-model.test.ts`: selected `gpt-4o`, `o3` and `ft:gpt-4.1-mini:...` refs resolve through `resolveDynamicModel` with the conservative listing row (reasoning only for `o3`). Without the hook change, all 3 fail; with it, the 3 OpenAI suites pass 84/84.

**Real OpenAI API key, isolated profiles** (`pnpm openclaw --profile <p> models list --provider openai --all --refresh --plain`; key read into process memory only):
- `/v1/models` listed 168 rows. `main` (`6070074`, this branch's base) shows **33**, this branch shows **36**. The 11 `main` rows that disappear are all pre-GPT-5: gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-4o, gpt-4o-mini, o1, o1-pro, o3, o3-mini, o3-pro, o4-mini. The 14 new rows are dated GPT-5 snapshots and `gpt-5.3-codex`.
- Each listed ID got one direct `/v1/responses` call. Every row shown here returned 200, except `gpt-daybreak-red-latest` (a manifest row `main` also shows; 404 for this key).
- Rows hidden on this branch, by family: image 10, realtime 10, transcription 7, TTS 7, audio 6, embeddings 3, moderation 2, `gpt-3.5-turbo-instruct` 2, Sora 2, Whisper 1, Babbage 1, Davinci 1, past shutdown date 18 (the other 7 already fall under a family above), experiment 22, search 4, cyber 2, alpha 2, live 1, pre-GPT-5 31.

**Real turns through an isolated Gateway:**
- `main`: `openai/gpt-4o-2024-11-20` fails with `Unknown model`.
- Branch, default runtime: every shown row was run in the earlier matrix, including the `*-pro` rows (only `o1-pro`, now hidden, was skipped for cost). All 35 shown rows other than `gpt-daybreak-red-latest` reply on the default (Codex) runtime. `chat-latest` and `gpt-5.5-2026-04-23` were re-run on `897f27f` and reply `ROW_OK` with `agentHarnessId: "codex"`. `gpt-daybreak-red-latest` fails on both runtimes with "model not found" for this key; `main` shows it too.
- Before the pre-GPT-5 rule, 29 shown rows failed on the default runtime with `Invalid value: 'custom'`; all 29 are now hidden.
- Upgrade check, `main` (`6070074`) vs this branch, one turn each, isolated profiles:
  1. `agents.defaults.model.primary: "openai/gpt-4o"` plus its `agentRuntime.id: "openclaw"`, nothing else: `main` replies `C1_OK`. Before the hook change, the branch failed with `Unknown model: openai/gpt-4o`; on this head it replies `C1_OK` (`agentHarnessId: "openclaw"`).
  2. Existing session with a `gpt-4o` override set through `sessions.patch` (`modelOverride: "gpt-4o"`), then a turn in that session: `main` replies `C2_OK`. Before the hook change, the branch failed with `Unknown model`; on this head it replies `C2_OK` (`agentHarnessId: "openclaw"`).
- With a `models.providers.openai` row for `gpt-4o` as well, it replies `GPT4O_OK` on `897f27f`.
- `models list --provider openai --all --refresh --plain` on this head still shows 36 rows, none of them pre-GPT-5.
- Hosted web search on old models: a direct `/v1/responses` call to `o3-mini` with `tools: [{ type: "web_search" }]` returns 400 "Tool 'web_search_preview' is not supported with o3-mini."; the same call without the tool returns 200. `docs/providers/openai/models.md` now says these models need `tools.web.search.provider` set to a managed provider or `tools.web.search.enabled: false` (the two switches `resolveNativeWebSearch` in `extensions/openai/native-web-search-policy.ts` checks, documented in `docs/tools/web.md#native-openai-web-search`).

**Shared default listing through a third-party plugin and a fake OpenAI-compatible server** (the xAI API-key path uses the same builder; no xAI key was available):
- `main`: `models list --provider listing-fixture --all --refresh --plain` shows only `fixture-known`, and a turn on `fixture-chat-next` fails with `Unknown model`.
- Branch: the same command shows `fixture-known` and `fixture-chat-next`. Embedding, realtime, image and audio rows stay hidden. The turn replies `FIXTURE_OK from fixture-chat-next`.

**Checks:** On `f6e1266`, `node scripts/check-changed.mjs` passes every lane except the dead-export scan, which fails only on `src/talk/client-voice-session-store.ts: ClientVoiceToolEffect`, a file this PR does not touch (same as on `897f27f`). `pnpm exec oxlint --type-aware` on the changed SDK files is clean. Focused tests on `f6e1266`: SDK live-runtime + strict 25/25, OpenAI API-key catalog + dynamic-model 44/44, xAI 47/47.

**Known gaps:** `gpt-5.6` would show with conservative metadata if listed, because the manifest has no row for it. The hosted-search restriction for gpt-3.5, gpt-4, gpt-4-turbo, gpt-4.1-nano, o1 and o3-mini is now documented and was checked with a raw `o3-mini` API call; a full OpenClaw turn on one of these models with web search off was not run. A selected pre-GPT-5 ref now resolves even when the key does not list it (`main` reported `Unknown model` for unlisted IDs), so such a turn fails at OpenAI instead of before the request.

No overlap with Pash/Sarah changes: `git log origin/main [email protected] [email protected]` shows no commits to the touched files.

**Merge danger:** two-way door. There are no schema, config, stored-data or protocol changes, and a revert restores the old lists. Blast radius: model pickers and `models list` for signed-in OpenAI API-key users, xAI API-key users, and plugins that call `buildLiveModelProviderConfig` without `projectRows`. The shared classifier's new exclusions also apply to every `liveModelDiscovery` provider. Pre-GPT-5 OpenAI models drop out of the browse lists but still resolve when referenced; on the default runtime they fail as they do on `main`. Worst case otherwise, a listed model that OpenClaw cannot drive shows up and fails on its first turn instead of being hidden.

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

## What Problem This Solves

Fixes: when you sign in to OpenAI with an API key, or to xAI or any provider that uses the shared live model listing, chat models the provider lists stay hidden from the model pickers until an OpenClaw release adds them.

## User Impact

User impact: signed-in users see every chat model their provider lists, including models released after their OpenClaw version. Catalog rows still supply names, prices and context limits for models OpenClaw already knows. Embedding, image, video, audio, realtime, speech, transcription, moderation, legacy-completions and retired models stay hidden.

On the OpenAI API-key listing, pre-GPT-5 families (GPT-3.5, GPT-4, GPT-4o, GPT-4.1, o1, o3, o4, and fine-tunes of them) are now hidden from `models list` and the pickers, including the 11 such rows `main` shows today. Ayaan chose this over changing the default runtime: these models fail on the default runtime, so listing them offers a choice that breaks on the first turn. GPT-5+ and IDs OpenClaw does not recognize keep appearing without a release.

Existing setups keep working: a pre-GPT-5 model named as the default model, an `agents.defaults.models` key, an allowlist entry or a session model override still resolves, with the same conservative metadata the listing used to give it. To use one, reference it and pin the OpenClaw runtime:

```json5
{
  agents: {
    defaults: {
      model: { primary: "openai/gpt-4o" },
      models: { "openai/gpt-4o": { agentRuntime: { id: "openclaw" } } },
    },
  },
}
```

## Why This Change Was Made

- **Shared listing.** `buildLiveModelProviderConfig` without `projectRows` used to keep only the static rows whose IDs were listed. It now runs listed rows through the existing shared chat classifier, the same one that `liveModelDiscovery` already uses. Static rows describe matching IDs, and other chat IDs get conservative rows. The plugin's `readModelId` selector still runs first (default: `id` on `object: "model"` rows, as on `main`): the ID it returns names the row, and a row it rejects stays out. Strict and advisory failure handling is unchanged: a failed listing keeps the fallback rows, and a successful empty listing stays empty. The direct consumer is the xAI API-key catalog. Third-party plugins that call this helper without `projectRows` get the same behavior; `docs/plugins/sdk-provider-plugins/model-catalogs.md` now describes this default and how `readModelId` restricts it.
- **Classifier.** The classifier also excludes realtime, audio, bare `image`/`video` IDs and legacy completions models (`babbage`, `davinci`, `gpt-3.5-turbo-instruct`), plus rows whose `shutdown_date` has passed. On the real OpenAI listing, all 25 rows with a past shutdown date fail on `/v1/responses` (22 × 404, 3 × 400). Exclusions also apply to IDs in the static catalog. `<modality>-text-to-text` kinds (Hugging Face vision/audio chat models) stay admitted.
- **OpenAI API key.** The catalog now uses the same shared builder. This removes the GPT-4o/4.1/5+/o family allowlist and the broad deny list from openclaw#162563. OpenClaw sends API-key turns through the Responses API, so narrow, named exclusions remain:
  - Pre-GPT-5 families (`^(?:ft:)?(?:gpt-3\.5|gpt-4|o[134])`): on the default runtime the Codex harness rejects every one of them with `400 Invalid value: 'custom'`, and 13 of them (gpt-3.5, gpt-4, gpt-4-turbo, gpt-4.1-nano, o1, o3-mini and snapshots) also reject hosted web search on the OpenClaw runtime. The rule also applies to catalog rows; the OpenAI manifest has none of these families (on `main` they came only from openclaw#162563's allowlist). Hiding only affects browsing: the OpenAI provider's `resolveDynamicModel` hook, which core calls only for a specific selected ref, returns the same conservative row for these IDs, so config defaults, allowlist entries and session overrides still resolve.
  - `search` models: Chat Completions only, per the [official model page](https://developers.openai.com/api/docs/models/gpt-4o-search-preview). On our key, `/v1/responses` returned 400 "not supported with the Responses API".
  - `live`, `cyber`, experiment (`exp`) and `alpha` codename IDs: our key lists them, but `/v1/responses` returns 404 or a persistent 500 for them.
  - Subscription-only route IDs (`gpt-5.3-codex-spark`) stay hidden, so the platform and ChatGPT routes stay separate.

  OpenAI IDs without a catalog row keep the existing conservative metadata from openclaw#162563 (Responses, text input, 128k context, 16,384 max output, reasoning for GPT-5+ and o-series, unknown cost). The shared prefix template is not used for OpenAI: every OpenAI ID starts with `gpt-`, so an unknown ID would inherit GPT-5 reasoning settings from an unrelated row.
- **xAI.** Multi-agent models stay hidden: they reject the client-side tools that every OpenClaw turn sends (documented xAI limitation).
- Retained gates: Anthropic `acceptUnknownModel`, OpenAI OAuth visibility, xAI OAuth backend eligibility, Google, Bedrock, Copilot, routed providers, replace mode and allowlists are unchanged.

## Evidence

**Regression tests (each fails on `main`, passes here):**
- `src/plugin-sdk/provider-catalog-live-runtime.test.ts`: a listed unknown chat ID shows. Realtime, audio, image, video, legacy-completions and past-shutdown rows stay out, including a static ID with image-only output. A Hugging Face `image-text-to-text` row stays. A failed listing keeps the static rows. The existing strict test still covers authoritative empty and failure.
- `src/plugin-sdk/provider-catalog-live-runtime.test.ts` (selector): a strict plugin whose selector reads `slug` keeps static `model-a`, admits an unknown `fresh-chat` slug, drops a `fresh-embedding` slug, and keeps out an ordinary `{ id: "model-b", object: "model" }` row the selector rejects. On `ceaccc6` it fails (received only `model-b`); on this head it passes.
- `extensions/openai/openai-api-key-catalog.test.ts`: dated snapshots, `gpt-5.3-codex` and a future `gpt-6.2` show with conservative metadata. `gpt-4-0613`, `gpt-4.1-mini`, `o3` and an `ft:gpt-4.1-mini:...` fine-tune stay hidden, as do search, live, cyber, experiment, alpha, subscription-only, non-chat and retired IDs. Without the pre-GPT-5 rule the test fails (1 failed, 6 passed); with it, 7/7 pass. A listing with only non-chat IDs is authoritative-empty.
- `extensions/xai/index.test.ts`: an unknown `grok-5-preview` shows. Multi-agent and `grok-imagine-*` stay hidden.
- `extensions/openai/openai-dynamic-model.test.ts`: selected `gpt-4o`, `o3` and `ft:gpt-4.1-mini:...` refs resolve through `resolveDynamicModel` with the conservative listing row (reasoning only for `o3`). Without the hook change, all 3 fail; with it, the 3 OpenAI suites pass 84/84.

**Real OpenAI API key, isolated profiles** (`pnpm openclaw --profile <p> models list --provider openai --all --refresh --plain`; key read into process memory only):
- `/v1/models` listed 168 rows. `main` (`618f4d2`, this branch's base) shows **33**, this branch shows **36**. The 11 `main` rows that disappear are all pre-GPT-5: gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-4o, gpt-4o-mini, o1, o1-pro, o3, o3-mini, o3-pro, o4-mini. The 14 new rows are dated GPT-5 snapshots and `gpt-5.3-codex`.
- Each listed ID got one direct `/v1/responses` call. Every row shown here returned 200, except `gpt-daybreak-red-latest` (a manifest row `main` also shows; 404 for this key).
- Rows hidden on this branch, by family: image 10, realtime 10, transcription 7, TTS 7, audio 6, embeddings 3, moderation 2, `gpt-3.5-turbo-instruct` 2, Sora 2, Whisper 1, Babbage 1, Davinci 1, past shutdown date 18 (the other 7 already fall under a family above), experiment 22, search 4, cyber 2, alpha 2, live 1, pre-GPT-5 31.

**Real turns through an isolated Gateway:**
- `main`: `openai/gpt-4o-2024-11-20` fails with `Unknown model`.
- Branch, default runtime: every shown row was run in the earlier matrix, including the `*-pro` rows (only `o1-pro`, now hidden, was skipped for cost). All 35 shown rows other than `gpt-daybreak-red-latest` reply on the default (Codex) runtime. `chat-latest` and `gpt-5.5-2026-04-23` were re-run on `897f27f` and reply `ROW_OK` with `agentHarnessId: "codex"`. `gpt-daybreak-red-latest` fails on both runtimes with "model not found" for this key; `main` shows it too.
- Before the pre-GPT-5 rule, 29 shown rows failed on the default runtime with `Invalid value: 'custom'`; all 29 are now hidden.
- Upgrade check, `main` (`618f4d2`) vs this branch, one turn each, isolated profiles:
  1. `agents.defaults.model.primary: "openai/gpt-4o"` plus its `agentRuntime.id: "openclaw"`, nothing else: `main` replies `C1_OK`. Before the hook change, the branch failed with `Unknown model: openai/gpt-4o`; on this head it replies `C1_OK` (`agentHarnessId: "openclaw"`).
  2. Existing session with a `gpt-4o` override set through `sessions.patch` (`modelOverride: "gpt-4o"`), then a turn in that session: `main` replies `C2_OK`. Before the hook change, the branch failed with `Unknown model`; on this head it replies `C2_OK` (`agentHarnessId: "openclaw"`).
- With a `models.providers.openai` row for `gpt-4o` as well, it replies `GPT4O_OK` on `897f27f`.
- `models list --provider openai --all --refresh --plain` on this head still shows 36 rows, none of them pre-GPT-5.
- Hosted web search on old models: a direct `/v1/responses` call to `o3-mini` with `tools: [{ type: "web_search" }]` returns 400 "Tool 'web_search_preview' is not supported with o3-mini."; the same call without the tool returns 200. `docs/providers/openai/models.md` now says these models need `tools.web.search.provider` set to a managed provider or `tools.web.search.enabled: false` (the two switches `resolveNativeWebSearch` in `extensions/openai/native-web-search-policy.ts` checks, documented in `docs/tools/web.md#native-openai-web-search`).

**Shared default listing through a third-party plugin and a fake OpenAI-compatible server** (the xAI API-key path uses the same builder; no xAI key was available):
- `main`: `models list --provider listing-fixture --all --refresh --plain` shows only `fixture-known`, and a turn on `fixture-chat-next` fails with `Unknown model`.
- Branch: the same command shows `fixture-known` and `fixture-chat-next`. Embedding, realtime, image and audio rows stay hidden. The turn replies `FIXTURE_OK from fixture-chat-next`.

**Checks:** On `f6e1266`, `node scripts/check-changed.mjs` passes every lane except the dead-export scan, which fails only on `src/talk/client-voice-session-store.ts: ClientVoiceToolEffect`, a file this PR does not touch (same as on `897f27f`). `pnpm exec oxlint --type-aware` on the changed SDK files is clean. Focused tests on `f6e1266`: SDK live-runtime + strict 25/25, OpenAI API-key catalog + dynamic-model 44/44, xAI 47/47.

**Known gaps:** `gpt-5.6` would show with conservative metadata if listed, because the manifest has no row for it. The hosted-search restriction for gpt-3.5, gpt-4, gpt-4-turbo, gpt-4.1-nano, o1 and o3-mini is now documented and was checked with a raw `o3-mini` API call; a full OpenClaw turn on one of these models with web search off was not run. A selected pre-GPT-5 ref now resolves even when the key does not list it (`main` reported `Unknown model` for unlisted IDs), so such a turn fails at OpenAI instead of before the request.

No overlap with Pash/Sarah changes: `git log origin/main [email protected] [email protected]` shows no commits to the touched files.

**Merge danger:** two-way door. There are no schema, config, stored-data or protocol changes, and a revert restores the old lists. Blast radius: model pickers and `models list` for signed-in OpenAI API-key users, xAI API-key users, and plugins that call `buildLiveModelProviderConfig` without `projectRows`. The shared classifier's new exclusions also apply to every `liveModelDiscovery` provider. Pre-GPT-5 OpenAI models drop out of the browse lists but still resolve when referenced; on the default runtime they fail as they do on `main`. Worst case otherwise, a listed model that OpenClaw cannot drive shows up and fails on its first turn instead of being hidden.

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

extensions: openai P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant