feat(settings): surface quota preflight cutoff in Settings → Routing - #12014
Closed
adivekar-utexas wants to merge 6 commits into
Closed
feat(settings): surface quota preflight cutoff in Settings → Routing#12014adivekar-utexas wants to merge 6 commits into
adivekar-utexas wants to merge 6 commits into
Conversation
Add a Quota Preflight Cutoff card to the routing settings page that enables the pre-existing resilience.quotaPreflight cutoff from the UI (it previously had no surface and the /api/resilience schema dropped the section via .strict()). When enabled, credential selection skips accounts whose remaining quota (5h/weekly/monthly/credits windows) is at or below the cutoff without sending a request upstream, falling back to the next account in the strategy order. Per-window cutoffs set on the Provider Quota page keep precedence over the global default. Wire quotaPreflight through updateResilienceSchema and the /api/resilience GET/PATCH round-trip, add the card component + en.json keys, and cover the schema/persistence path with unit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
The i18n parity gate (i18n-pt-br.test.ts) fails when en.json gains keys that pt-BR.json lacks. Mirror the new settings.quotaPreflight* keys into pt-BR.json (English fallbacks for now, same pattern as other untranslated keys) so the UI-coverage CI shard goes green. Co-authored-by: Cursor <cursoragent@cursor.com>
The i18n completeness gates (i18n-vi-completeness, i18n-pt-br, and the locale-parity family in CI) require every locale to carry the same keys as en.json. Mirror the new settings.quotaPreflight* keys into all 41 non-English locale files using the English strings as fallbacks, matching the established pattern for untranslated keys. Co-authored-by: Cursor <cursoragent@cursor.com>
…ction The resilience HTTP e2e pins the exact /api/resilience response key set. Adding quotaPreflight to the GET projection (Settings → Routing quota preflight card, diegosouzapw#12014) requires updating this expectation — the response must expose the configuration for the card to load it. Co-authored-by: Cursor <cursoragent@cursor.com>
…own) Co-authored-by: Cursor <cursoragent@cursor.com>
…ing page-data collection; all other jobs green) Co-authored-by: Cursor <cursoragent@cursor.com>
Owner
|
@adivekar-utexas — confirmei que #12090 é esta PR + 3 commits extras (refactor do context_length routing) na mesma branch/autor ( |
diegosouzapw
pushed a commit
that referenced
this pull request
Aug 30, 2026
) Honra um `context_length` definido pelo operador em tempo de requisição no roteamento do combo (supersede #12014, que estava incluída nos mesmos commits). Boa cobertura de testes, incluindo o refactor de `resolveComboContextLimit` para módulo próprio. Validado no worktree combinado (13/13). Obrigado!
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.
Summary
The quota-preflight cutoff (
resilience.quotaPreflight) already exists in the runtime (it arms credential selection to skip accounts whose remaining quota has hit a cutoff without sending the request upstream), but it had no UI surface — and the/api/resiliencePATCH schema silently rejected the section (.strict()dropped it), so it could only be enabled via env var.This PR surfaces it in Settings → Routing as a "Quota Preflight Cutoff" card:
Cutoffmodal per connection,quotaWindowThresholds) and per-provider window defaults keep precedence; the global default only applies to windows without their own cutoff.What changed
src/shared/validation/schemas/settings.ts— addedquotaPreflightSettingsSchemaand wired it intoupdateResilienceSchema(previously the section was dropped by.strict()).src/app/api/resilience/route.ts— GET/PATCH now round-tripquotaPreflight(PATCH was already computing it viamergeResilienceSettings; it just wasn't accepted on input or returned).src/app/(dashboard)/dashboard/settings/components/QuotaPreflightCard.tsx— new card (loads fromGET /api/resilience, saves viaPATCH /api/resiliencewith{ quotaPreflight }).src/app/(dashboard)/dashboard/settings/routing/page.tsx— mounts the card under the existing Routing Strategy card.src/i18n/messages/en.json— keys for the card (other locales fall back to English via the existingtx()pattern used elsewhere in the settings UI).tests/unit/quota-preflight-routing-ui.test.ts— 3 tests: schema accepts the section, schema rejects malformed values, persistedenabled: trueresolves throughresolveResilienceSettings(the flagauth.tsreads to arm the preflight latency gate).Behavior notes
enabled: falsefactory default; enabling via env varQUOTA_PREFLIGHT_CUTOFF_ENABLEDstill works).getProviderCredentialsWithQuotaPreflight) checks each candidate account's quota windows (5h / weekly / monthly / credits, whatever the provider's quota fetcher exposes — e.g. Command Code'sfive_hour/weekly/credits) against the cutoff and skips exhausted accounts, falling back to the next account in the strategy order without making an upstream request to the skipped account. This is exactly the "skip out-of-quota accounts in priority order without wasting time" behavior.429 allRateLimitedwith the earliest reset time instead of dispatching to an exhausted account.Test plan
tests/unit/quota-preflight-routing-ui.test.ts— 3/3 pass.tests/unit/sse-auth.test.ts— 66/66 pass (preflight gating + sibling selection).tests/unit/combo-priority-quota-exhaustion-cutoff-5923.test.ts,tests/unit/quota-exhaustion-cutoff-opencode.test.ts,tests/unit/issue-6686-quota-preflight-coverage.test.ts— 9/9 pass.npx tsc --noEmit -p tsconfig.typecheck-core.json— clean.npx eslinton the new/changed non-barrel files — clean (pre-existing barrel-level unused-import errors inschemas/settings.tsare untouched).