fix(service-tier): make /fast work on ChatGPT-subscription Codex models - #547
Merged
code-yeongyu merged 2 commits intoJul 31, 2026
Merged
Conversation
…dex /fast (LAB-12) `/fast` on an `openai-codex` model looks for a `-fast` catalog sibling that `generate-models.ts` only emits for the direct `openai` provider, so the command always fell through to the "not available on a ChatGPT subscription" notice added in code-yeongyu#503. That notice was wrong. Measured with a live ChatGPT Pro token: `chatgpt.com/backend-api/codex/models?client_version=0.145.0` advertises `service_tiers: [{ id: "priority", name: "Fast", description: "1.5x speed, increased usage" }]` for gpt-5.4/5.5/5.6-*, and the first-party Codex CLI sends `service_tier: "priority"` on subscription OAuth. The SSE echo that code-yeongyu#503 relied on reports `auto`/`default` whether or not a tier was sent, so it proves nothing. The no-variant branch now flips a session-scoped priority tier that the existing `before_provider_request` handler injects into the Codex payload. Session-only, reset on `session_start`, and an explicit model/scoped tier still wins. Fixes code-yeongyu#545
The session toggle added in the previous commit had one payload assertion. Cover the transitions that a real session actually goes through: - switching to another Codex model mid-session keeps sending the tier, since fast mode is a session intent rather than a property of the selected model - hopping to a non-OpenAI model stops sending it - an explicitly configured model tier still wins over the toggle - `session_start` drops the toggle so a fresh session never inherits it Each assertion was mutation-proved: removing the injection fails three cases, whitelisting anthropic-messages fails two, inverting precedence fails one, and dropping the `session_start` reset fails one.
This was referenced Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #545. Reverses the conclusion of my own #503: the ChatGPT Codex backend does offer a priority ("Fast") tier to subscription accounts, so
/fastshould work there.Why the previous notice was wrong
/fastis registered foropenai-codexbut switches through anopenai-codex/<id>-fastcatalog sibling thatgenerate-models.tsonly emits for the directopenaiprovider. #503 turned that dead end into a notice claiming priority tier is unavailable on a ChatGPT subscription. Its evidence was the SSEservice_tierecho — and that echo carries no information:response.createdechoresponse.completedechopriorityautodefaultautodefaultdefaultautodefaultauto/flex/scaleUnsupported service_tierIdentical echoes for
priorityand for sending nothing, so the echo cannot distinguish the tier that served the request.What the backend and the first-party client actually do
GET https://chatgpt.com/backend-api/codex/models?client_version=0.145.0withoriginator: codex_cli_rsand a live ChatGPT Pro token (chatgpt_plan_type: pro) returns, per model:service_tiersadditional_speed_tiers[{"id":"priority","name":"Fast","description":"1.5x speed, increased usage"}]["fast"][][]"1.5x speed, increased usage"is the backend's own description of the tier, returned to a subscription account.Official
@openai/codex0.145.0 on ChatGPT OAuth (requires_openai_auth = true), routed through a local logging proxy tochatgpt.com:service_tier = "priority"inconfig.toml→POST /backend-api/codex/responsesbody contains"service_tier": "priority", turn completes (200)service_tierSo this is not an API-key-only field.
The change
When an
openai-codexmodel has no compatible-fastcatalog sibling,/fastnow flips a session-scoped priority tier instead of reporting the feature unavailable. The existingbefore_provider_requesthandler injects it —addServiceTierToPayloadalready whitelistsopenai-codex-responsesandapi/openai-codex-responses.tsalready forwardsoptions.serviceTier— so there is no core or provider change. The catalog-variant path for the directopenaiprovider is untouched.Semantics:
session_startserviceTier(models.json,provider/id:tier) still winsTests
test/suite/service-tier-extension.test.ts(11 cases, all green) now covers the toggle payload, a mid-session switch to another Codex model keeping the tier, a hop to an Anthropic model dropping it, explicit-tier precedence, and thesession_startreset. Each new assertion was mutation-proved — removing the injection fails 3 cases, leaking the tier to every api fails 2, inverting precedence fails 1, dropping the reset fails 1.Manual QA
Real TUI, subscription OAuth, provider
baseUrlpointed at a logging proxy, request bodies decoded:npm run checkclean;packages/coding-agenttest/suitegreen apart from a pre-existingapp-server-thread-handlers-archivetimestamp-monotonicity flake that also fails with this change stashed.Open question
getServiceTierCostMultiplier()inapi/openai-codex-responses.tsmultiplies displayed cost by 2 (2.5 for gpt-5.5) forpriority. On a subscription the dollar figure is notional ((sub)in the footer) but the backend does say "increased usage", so I left the multiplier alone rather than guessing a subscription-specific number. Happy to change it if you have a preference.Summary by cubic
Enables Fast mode on ChatGPT-subscription Codex models by toggling a session-scoped
prioritytier when no-fastcatalog variant exists. This makes/fastwork onopenai-codexmodels and replaces the incorrect “unavailable on subscription” notice. Fixes #545./fastnow toggles a sessionprioritytier foropenai-codexmodels without a-fastsibling, with notify messages for enabled/disabled.before_provider_requestforopenai-codex-responses; other providers unchanged.session_start; explicit modelserviceTierstill wins; switching between Codex models keeps the tier; moving to non-OpenAI drops it.Written for commit 144048a. Summary will update on new commits.