Repository navigation
Studio: offer only the Codex models the ChatGPT plan can actually reach - #9302
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc2ba917d4
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| allowed_models = set(info.get("default_models", [])) | ||
| allowed_models |= offered_subscription_model_ids(payload.provider_id) |
There was a problem hiding this comment.
Stop treating every seed model as plan-approved
For a newly connected provider, ensureCodexProvider persists every curated default before plan discovery, and normal backend synchronization continues publishing those saved IDs. Because this gate permanently includes all defaults, a Go account can still select a saved gpt-5.6-sol and reach the same upstream 400 even after /codex/models omitted it. Once a subscription catalog has been fetched, gate or reconcile models against that plan-specific catalog rather than the entire seed.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. visibility: "list" says what a picker should offer, not what the account is allowed to call. Slugs flip to "hide" as they age while staying usable, so gating chat on the listed set would locally refuse a saved model that still works upstream. The gate stays permissive (seed plus listed), and a plan that genuinely rejects a model now returns its own reason, since this PR surfaces the bare detail body verbatim instead of discarding it. Reconciling a stale saved selection is already handled where the catalog is known: the editor drops slugs the plan does not list when it opens, which is where a Go account stops being offered gpt-5.6-sol.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41a4ed8cc7
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| _models_cache[provider_id] = (time.time() + _MODELS_CACHE_TTL_SECONDS, models) | ||
| _offered_models[provider_id] = {model["id"]: model for model in models} | ||
| _catalog_accounts[provider_id] = account_id |
There was a problem hiding this comment.
Reject stale catalog responses after account rebinding
When account A's catalog request is still in flight while this provider is reauthorized to account B, B's request can finish first and then A's older response unconditionally overwrites all three caches here. Fresh evidence beyond the earlier account-cache fix is that account identity is checked only before the request, never again before committing its response. Until another catalog fetch detects the mismatch, the picker and chat gate can use account A's dynamic slugs for account B, producing invalid selections and upstream failures; guard the write with the current account or a request generation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not taking this one. The write is unguarded as you say, but the interleaving needs a /codex/models GET for account A to still be in flight at the moment a reauthorization to account B completes. B's completion requires the browser or device OAuth round trip, which is seconds of human interaction, while the GET is a single request under httpx.Timeout(120.0, connect = 20.0) and normally answers in well under a second. The two do not overlap in a real session. The state is also self correcting rather than sticky: the next fetch for B hits the account check at the top of list_subscription_models, forgets A's catalog and refetches, and until then the only effect is that a slug B's plan does not list reaches upstream and comes back with its own reason, which this PR surfaces verbatim. Happy to revisit with a concrete sequence where the GET is still open when the OAuth flow lands.
|
@codex review |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ebe1710c6
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| setAvailableModels(picker.catalog); | ||
| if (refresh) { | ||
| // The checkboxes stay live while the request is out, so reconcile against the | ||
| // latest selection rather than the snapshot taken when the reload began. This is | ||
| // what the remote-catalog path above already does. | ||
| const offered = new Set(picker.catalog); | ||
| setSelectedModelIds((previous) => previous.filter((id) => offered.has(id))); | ||
| } else { | ||
| setSelectedModelIds(picker.selected); |
There was a problem hiding this comment.
Reconcile the active provider after loading its catalog
When a newly connected or reauthorized account returns a successful subscription catalog, this updates only the form's selectedModelIds; the preceding sync has already published the backend's old seed/saved list through onProvidersChange, and the main model picker builds its options from that provider list (chat-page.tsx:3195-3204). If the user closes the form without clicking Save, models absent from known remain selectable and are then rejected by the chat gate. Fresh evidence beyond the rejected seed-gating comment is that resolveCodexPickerModels has already distinguished truly absent slugs from merely hidden ones here, but that authoritative result never reaches the active provider store.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this. Two independent reviews reached the same verdict, and I verified the load-bearing points against the source myself. The mechanism is described accurately, but the framing that the Codex path is asymmetric does not hold: the generic path publishes only availableModels, and its own selection prune is equally form-local, so the two paths behave the same way. availableModels is also not what the picker builds its options from; its only chat-side consumer is the hint about whether a provider withdrew a model or the user unticked it. The behaviour is pre-existing and strictly better than before this PR: openai_codex is model_list_mode curated and not in the remote-catalog custom set, so previously editProvider took the curated branch and offered the whole six-model seed unconditionally, with no catalog reconciliation at all and no Save required. Nothing is persisted without Save either, since the only two providers_db.update_provider callers are both inside update_provider_config, and the models endpoint never touches the database. One thing worth separating out, which neither the item nor the review raised as part of this verdict: once a catalog is known the gate admits only offered ids plus saved slugs the catalog carries, so if the models endpoint ever under-reports what the responses endpoint would accept, this PR turns a previously working send into a local 400. That is a premise of the design rather than a defect here, guarded by the bail when nothing offerable comes back, but it is the one place the PR could refuse something that would otherwise have worked. Separately, the message Choose a curated Codex model reads misleadingly for a slug that is in the curated seed.
The rollback restored all six metadata columns from the snapshot read at the top of the handler, before any await. remember_catalog_account suspends on a file lock with a 30 second timeout, and the failure the rollback exists for is exactly the one where that lock was contended for the full 30 seconds, so the window is widest when it fires. A second save that commits inside that window was silently reverted. Restore only the columns this request set, and only where the row still holds this request's value. A column a later save owns is left alone.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b94a8fcd4e
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # the row's own slugs stop authorizing chat and the next save is refused as well. | ||
| if validated_account: | ||
| try: | ||
| await openai_codex_auth.remember_catalog_account(provider_id, validated_account) |
There was a problem hiding this comment.
Fail the save when account proof is declined
When a save containing an account-A-only dynamic slug commits while reauthorization switches the bundle to account B before this await acquires the OAuth guard, remember_catalog_account returns normally without writing because the account IDs no longer match. This handler treats that return as success, leaves the account-A selection persisted, and reports a successful save even though the now-stale catalog gate rejects that model for account B. Have the helper signal this mismatch so the save can roll back or retry.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this, though two of the three premises are correct. The silent return is real: openai_codex_auth.py returns None when the bundle account no longer matches, indistinguishable from the successful write, and the call site only catches exceptions so the rollback never fires. Reachability is real too, and it does not even need a second request: the only rebinding writer is the bundle persister, which for the loopback flow fires from a background task, and the guard is a file lock acquired through asyncio.to_thread so there is a genuine suspension. What settles it is the control. A plain account switch with zero concurrency produces a byte-identical end state: row keeps the same models, proof None, not proven for the new account, later save refused. save_oauth_bundle overwrites the bundle wholesale, so any rebind clears catalog_account_id regardless of whether a save was in flight. That is the expected outcome of switching accounts and finding an old selection invalid, not a concurrency defect. Nor did the PUT lie: it returned 200 with the models the row genuinely holds, and it never asserted anything about the account, which is the difference from the two earlier items in this area, where one reported failure while persisting a change and the other erased a third party's save. It also self-heals with nothing lost once the new account's catalog is fetched, which a rebind forces. The suggested rollback would discard a save that was correctly validated against the previous account because a background OAuth completion landed concurrently, restore a value equally unusable under the new account, and reintroduce the reported-failure-with-persisted-change tear that b0390ab removed. The stale gate refusing the model is the safety net working, and test_codex_save_records_only_the_account_it_actually_validated already pins it.
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Before and after for the model list this PR changes, from two isolated Studio installs built from the merge base (32ba55b) and from the head (b94a8fc). Not from main, so the pair credits this PR alone. Settings, Connections, Add connection, with the Codex provider selected and no ChatGPT account linked. The counter goes from 7 models to 6 and the retired gpt-5.3-codex-spark leaves the top of the list. The other six ids and their order are unchanged. Read back from the same server that was photographed, so the numbers are diffable rather than counted by eye:
The capability map moves with the list, so no orphan entry is left behind for the retired slug. That one is not visible in the screenshot. One limitation worth stating plainly rather than implying broader coverage. The headline behaviour, the picker offering only the models a connected plan actually returns, is not reproducible on this machine: it needs a real ChatGPT account, and _validated_models_url pins scheme, host, port and path with no environment override, so pointing it at a local stub would mean editing the code under test and photographing something other than this PR. What is shown above is the part of the change that is reachable with no account connected. The plan-scoped catalog path is covered by the backend and frontend tests in this PR instead. |

The ChatGPT/Codex provider offered a hardcoded model list that ignores what the account's plan supports. Picking gpt-5.3-codex-spark failed with a bare ChatGPT Codex request failed (400). upstream rejects it for ChatGPT accounts entirely, and the real reason was discarded because the error extractor only parsed {"error": {...}} while this endpoint returns {"detail": ...}. gpt-5.6-sol fails the same way on a Go plan.
Fetch the account's real list from /backend-api/codex/models and drive the picker from it, keeping only visibility: "list" slugs and falling back to the curated seed when disconnected or when upstream is unreachable. Drop gpt-5.3-codex-spark from the registry and from selections saved earlier, and surface bare detail error bodies.