Skip to content

fix(sse): canonicalize alias provider ids before quota fetcher lookup (#10877) - #10922

Merged
diegosouzapw merged 1 commit into
release/v3.8.50from
fix/10877-quota-alias-lookup
Aug 21, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.50from
fix/10877-quota-alias-lookup

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Closes #10877

⚠️ base-red inherited: #9985 (unrelated, tracked separately)

Root cause

getResetAwareProvider() (open-sse/services/combo/quotaScoring.ts) returned the raw, lowercased provider/providerId from a combo target with zero alias canonicalization. That raw value feeds getQuotaFetcher(provider) in quotaStrategies.ts (reset-aware / reset-window strategies) and in combo.ts (auto-combo candidate scoring). Fetchers are registered under canonical provider ids (e.g. ollama-cloud, codex), while provider definitions declare separate alias spellings (e.g. ollamacloud, cx) that combo targets can carry as target.provider/target.providerId. A fetcher registered under the canonical id was therefore silently missed for any target stored under an alias spelling, degrading quota-aware routing to plain priority ordering with no warning.

The exact same alias class is already correctly canonicalized elsewhere (accountFallback.ts::getCanonicalLockProvider → resolveProviderId()) for per-model lockout tracking; this PR reuses that resolver in the quota path.

Fix

  • getResetAwareProvider() now canonicalizes via resolveProviderId() before returning, fixing both quotaStrategies.ts:74 and quotaStrategies.ts:264 (both call sites derive provider from this function).
  • The separate raw getQuotaFetcher(provider) call in combo.ts (auto-combo candidate scoring / buildAutoCandidates) is also canonicalized at the fetcher-lookup site only, without touching the other uses of that provider variable (circuit breaker, historical latency keying, connection grouping) to keep the diff scoped.

Regression test (TDD)

tests/unit/quota-scoring-alias-lookup-10877.test.ts:

  • confirms getResetAwareProvider() now returns the canonical id (was RED before the fix — asserted 'ollamacloud' actual vs 'ollama-cloud' expected)
  • confirms a fetcher registered under the canonical id (ollama-cloud) is now found for an alias-spelled target (ollamacloud)
  • confirms already-canonical provider ids (codex) are unaffected (no cache-key drift for non-aliased providers)
  • confirms null is still returned when neither providerId nor provider is set

Verification

  • node --import tsx/esm --test tests/unit/quota-scoring-alias-lookup-10877.test.ts → RED before fix, GREEN after
  • Sibling suites re-run green: generic-quota-fetcher, ollama-cloud-usage, combo/reset-window-strategy-9330, headroom-codex-quota-snapshot-6379, opencode-quota-fetcher, combo-lockout-quota-reset-6863, combo-quota-exhaustion-only-fallback, combo-priority-quota-exhaustion-cutoff-5923, combo-quota-soft-penalty, combo/auto-quota-cutoff, combo-strategies (116/116 pass)
  • npx vitest run --config vitest.mcp.config.ts open-sse/services/combo/__tests__ open-sse/services/autoCombo/__tests__ open-sse/services/__tests__/antigravity-quota-family.test.ts → 109/109 pass
  • npm run typecheck:core clean
  • npx eslint --suppressions-location config/quality/eslint-suppressions.json <changed files> clean
  • node scripts/check/check-file-size.mjs OK
  • node scripts/check/check-complexity.mjs OK (2573 vs baseline 2774)
  • node scripts/check/check-cognitive-complexity.mjs OK (1157 vs baseline 1223)
  • node scripts/check/check-changelog-integrity.mjs OK

Optional follow-up noted in the analysis plan-file but out of scope here: emit a deduplicated log.warn when a combo member still has no fetcher after canonicalization, so degradation to priority ordering is no longer silent.

@diegosouzapw
diegosouzapw merged commit 1f04e73 into release/v3.8.50 Aug 21, 2026
11 checks passed
@diegosouzapw
diegosouzapw deleted the fix/10877-quota-alias-lookup branch August 21, 2026 15:33
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…7-quota-alias-lookup

fix(sse): canonicalize alias provider ids before quota fetcher lookup (cheaper-inference#10877)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(combos): reset-aware/reset-window silently degrade to priority when combo members lack a quota fetcher

2 participants