Repository navigation
fix(core): restore ChatGPT model discovery for token sharing - #64528
rekram1-node wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
The change looks sound. I couldn't test discovery live (no ChatGPT credentials). The plugin tests pass (29/29, and 145/145 over 5 repeat runs) and tsc -b for packages/core passes.
I read the restored refresh path closely:
- Late answers are dropped when the credential or cache key changed while the request was pending.
- Failures, timeouts, bad bodies and empty or filtered-to-empty lists keep the current list and save nothing. A failure only logs a warning.
- The new
models:<credential>:<client>key prevents one account's list from showing under another account that reuses the same client ID. - Not seeding the old
models:<clientID>snapshot during migration matches the stated intent.
The trade-off you call out is the main risk: for accounts whose /v1/models list leaves out a model they can still use (the #52878 case), that model disappears again until OpenAI lists it. Config-defined models stay visible, so users have a workaround.
A small side effect: entries under the old models:<clientID> key are no longer read but stay in plugin storage.
Public API: unchanged. The plugin storage keys are internal.
Related: #52878
|
I opened #65417 for the same area and it was closed as a duplicate of this one, which is right — this is the better PR and it has the per-credential keying and the stale-answer guard that mine did not have. One difference is worth making the case on here, since the trade-off is spelled out above: adding the account's list to the fixed list instead of replacing it. The case for the union:
So the change on top of this PR would be small — the union, and // the models the sign-in serves are the fixed set plus the ones the account's
// list names; the account's list only adds, because it omits models the
// sign-in still serves
const reported = available?.map((model) => model.slug)
const supported = catalog.filter(
(model) => fallbackModels.has(model.id) || reported?.includes(model.modelID),
)
models: available ? deriveModels(available, supported) : supportedwith I have that version written and tested ( Happy to drop it if you think the replacement is the right call — the argument above is only about not losing the fixed models, and you have the account data to judge whether that matters. |
34d106f to
80f9525
Compare
Issue for this PR
Related: #52878 (sync turned off in #53466 while OpenAI's
/v1/modelsleft out models some accounts could use)Type of change
What does this PR do?
Sign in with ChatGPT shows one list for every account: the models.dev
openai-chatgptlist since #65579, or the built-in list. Some plans can't use every model on it (the Codex catalog marksgpt-6.2-*as unavailable on free plans, for example). This turns the per-account model sync back on, using the code that was commented out. Like GitHub Copilot, the account's live list decides what shows, and the models.dev list stands in until it loads or when it fails.A token-sharing token sent to
GET https://api.openai.com/v1/modelsreturned 200 on 2026-11-22: 12 models, 10 withvisibility: "list"andsupported_in_api(the 6.2, 6.1, 6 and 5.6 models), matching the existing schema.It uses the same plumbing as GitHub Copilot's model list (
ProviderRefresh.startwithSharedCache), so one fetch serves every open project:Notes:
chatgpt-browserstill strips the oldmodelsfrom credential metadata.-fast,-pro, ...) are kept only when the models.dev list (or the built-in one) has them. This route rejectsservice_tier: "flex"(tested live), so-flexstays hidden.Trade-off: when discovery succeeds, the account list decides what shows up. If OpenAI leaves out a model the account can still use, which is the bug from #52878, it disappears until the list includes it. The models.dev list is used only when there is no usable account list; merging the two would show models the account may not be able to use.
How did you verify your code works?
packages/core/test/plugin/provider-chatgpt.test.ts, with controlled HTTP responses and the test clock:-fastkept from the models.dev list,-flexhidden.Rebased on
devafter #65579.provider-chatgpt.test.tspasses with--rerun-each 5;provider-openai.test.ts,provider-github-copilot.test.tsandmodels.test.tspass.bun typecheckinpackages/corepasses.Not tested: a live run of this build against a ChatGPT account.
Checklist