Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
feat(codex): add account-level 5h/weekly quota policy and auto-rotation
rexname0e30d15c0112
diff --git a/README.md b/README.mdindex b48c28b98f..69fe17227e 100644--- a/README.md+++ b/README.md@@ -1292,6 +1292,23 @@ Models:cx/gpt-5.1-codex-max```+#### Codex Account Limit Management (5h + Weekly)++Each Codex account now has policy toggles in `Dashboard -> Providers`:++- `5h` (ON/OFF): enforce the 5-hour window threshold policy.+- `Weekly` (ON/OFF): enforce the weekly window threshold policy.+- Threshold behavior: when an enabled window reaches >=90% usage, that account is skipped.+- Rotation behavior: OmniRoute routes to the next eligible Codex account automatically.+- Reset behavior: when the provider `resetAt` time passes, the account becomes eligible again automatically.++Scenarios:++- `5h ON` + `Weekly ON`: account is skipped when either window reaches threshold.+- `5h OFF` + `Weekly ON`: only weekly usage can block the account.+- `5h ON` + `Weekly OFF`: only 5-hour usage can block the account.+- `resetAt` passed: account re-enters rotation automatically (no manual re-enable).+### Gemini CLI (FREE 180K/month!)```bashdiff --git a/docs/i18n/README.md b/docs/i18n/README.mdindex b3407af2a9..bd0cf76ce8 100644--- a/docs/i18n/README.md+++ b/docs/i18n/README.md@@ -9,4 +9,13 @@ This directory contains machine-assisted translations based on the English docs.- **TROUBLESHOOTING.md**: 🇺🇸 [English](../TROUBLESHOOTING.md) | 🇧🇷 [Português (Brasil)](./pt-BR/TROUBLESHOOTING.md) | 🇪🇸 [Español](./es/TROUBLESHOOTING.md) | 🇫🇷 [Français](./fr/TROUBLESHOOTING.md) | 🇮🇹 [Italiano](./it/TROUBLESHOOTING.md) | 🇷🇺 [Русский](./ru/TROUBLESHOOTING.md) | 🇨🇳 [中文 (简体)](./zh-CN/TROUBLESHOOTING.md) | 🇩🇪 [Deutsch](./de/TROUBLESHOOTING.md) | 🇮🇳 [हिन्दी](./in/TROUBLESHOOTING.md) | 🇹🇭 [ไทย](./th/TROUBLESHOOTING.md) | 🇺🇦 [Українська](./uk-UA/TROUBLESHOOTING.md) | 🇸🇦 [العربية](./ar/TROUBLESHOOTING.md) | 🇯🇵 [日本語](./ja/TROUBLESHOOTING.md) | 🇻🇳 [Tiếng Việt](./vi/TROUBLESHOOTING.md) | 🇧🇬 [Български](./bg/TROUBLESHOOTING.md) | 🇩🇰 [Dansk](./da/TROUBLESHOOTING.md) | 🇫🇮 [Suomi](./fi/TROUBLESHOOTING.md) | 🇮🇱 [עברית](./he/TROUBLESHOOTING.md) | 🇭🇺 [Magyar](./hu/TROUBLESHOOTING.md) | 🇮🇩 [Bahasa Indonesia](./id/TROUBLESHOOTING.md) | 🇰🇷 [한국어](./ko/TROUBLESHOOTING.md) | 🇲🇾 [Bahasa Melayu](./ms/TROUBLESHOOTING.md) | 🇳🇱 [Nederlands](./nl/TROUBLESHOOTING.md) | 🇳🇴 [Norsk](./no/TROUBLESHOOTING.md) | 🇵🇹 [Português (Portugal)](./pt/TROUBLESHOOTING.md) | 🇷🇴 [Română](./ro/TROUBLESHOOTING.md) | 🇵🇱 [Polski](./pl/TROUBLESHOOTING.md) | 🇸🇰 [Slovenčina](./sk/TROUBLESHOOTING.md) | 🇸🇪 [Svenska](./sv/TROUBLESHOOTING.md) | 🇵🇭 [Filipino](./phi/TROUBLESHOOTING.md)- **USER_GUIDE.md**: 🇺🇸 [English](../USER_GUIDE.md) | 🇧🇷 [Português (Brasil)](./pt-BR/USER_GUIDE.md) | 🇪🇸 [Español](./es/USER_GUIDE.md) | 🇫🇷 [Français](./fr/USER_GUIDE.md) | 🇮🇹 [Italiano](./it/USER_GUIDE.md) | 🇷🇺 [Русский](./ru/USER_GUIDE.md) | 🇨🇳 [中文 (简体)](./zh-CN/USER_GUIDE.md) | 🇩🇪 [Deutsch](./de/USER_GUIDE.md) | 🇮🇳 [हिन्दी](./in/USER_GUIDE.md) | 🇹🇭 [ไทย](./th/USER_GUIDE.md) | 🇺🇦 [Українська](./uk-UA/USER_GUIDE.md) | 🇸🇦 [العربية](./ar/USER_GUIDE.md) | 🇯🇵 [日本語](./ja/USER_GUIDE.md) | 🇻🇳 [Tiếng Việt](./vi/USER_GUIDE.md) | 🇧🇬 [Български](./bg/USER_GUIDE.md) | 🇩🇰 [Dansk](./da/USER_GUIDE.md) | 🇫🇮 [Suomi](./fi/USER_GUIDE.md) | 🇮🇱 [עברית](./he/USER_GUIDE.md) | 🇭🇺 [Magyar](./hu/USER_GUIDE.md) | 🇮🇩 [Bahasa Indonesia](./id/USER_GUIDE.md) | 🇰🇷 [한국어](./ko/USER_GUIDE.md) | 🇲🇾 [Bahasa Melayu](./ms/USER_GUIDE.md) | 🇳🇱 [Nederlands](./nl/USER_GUIDE.md) | 🇳🇴 [Norsk](./no/USER_GUIDE.md) | 🇵🇹 [Português (Portugal)](./pt/USER_GUIDE.md) | 🇷🇴 [Română](./ro/USER_GUIDE.md) | 🇵🇱 [Polski](./pl/USER_GUIDE.md) | 🇸🇰 [Slovenčina](./sk/USER_GUIDE.md) | 🇸🇪 [Svenska](./sv/USER_GUIDE.md) | 🇵🇭 [Filipino](./phi/USER_GUIDE.md)+## Recent note: Codex account limit policy++Documentation now includes Codex account-level quota policy behavior:++- Per-account toggles: `5h` and `Weekly` (ON/OFF).+- Threshold policy: enabled window reaching >=90% marks account as ineligible for selection.+- Auto-rotation: traffic moves to the next eligible Codex account.+- Auto-reuse: account becomes eligible again after provider `resetAt` passes.+Generated on 2026-02-26.diff --git a/docs/i18n/id/README.md b/docs/i18n/id/README.mdindex f1f2b4542c..ead4c2a4ae 100644--- a/docs/i18n/id/README.md+++ b/docs/i18n/id/README.md@@ -1059,6 +1059,23 @@ Models:cx/gpt-5.1-codex-max```+#### Manajemen Limit Akun Codex (5h + Mingguan)++Setiap akun Codex sekarang punya toggle kebijakan di `Dashboard -> Providers`:++- `5h` (ON/OFF): menerapkan kebijakan ambang untuk jendela 5 jam.+- `Weekly` (ON/OFF): menerapkan kebijakan ambang untuk jendela mingguan.+- Perilaku ambang: saat jendela yang aktif mencapai >=90% penggunaan, akun tersebut di-skip.+- Perilaku rotasi: OmniRoute otomatis merutekan ke akun Codex berikutnya yang masih eligible.+- Perilaku reset: saat waktu `resetAt` provider sudah lewat, akun otomatis bisa dipakai lagi.++Skenario:++- `5h ON` + `Weekly ON`: akun di-skip jika salah satu jendela mencapai ambang.+- `5h OFF` + `Weekly ON`: hanya penggunaan mingguan yang bisa memblokir akun.+- `5h ON` + `Weekly OFF`: hanya penggunaan 5 jam yang bisa memblokir akun.+- `resetAt` sudah lewat: akun otomatis masuk rotasi lagi (tanpa enable manual).+### Gemini CLI (GRATIS 180K/bulan!)```bashdiff --git a/src/app/(dashboard)/dashboard/providers/[id]/page.tsx b/src/app/(dashboard)/dashboard/providers/[id]/page.tsxindex a96cf62888..a25668823d 100644--- a/src/app/(dashboard)/dashboard/providers/[id]/page.tsx+++ b/src/app/(dashboard)/dashboard/providers/[id]/page.tsx@@ -311,6 +311,58 @@ export default function ProviderDetailPage() {}};+ const handleToggleCodexLimit = async (connectionId, field, enabled) => {+ try {+ const target = connections.find((connection) => connection.id === connectionId);+ if (!target) return;++ const providerSpecificData =+ target.providerSpecificData && typeof target.providerSpecificData === "object"+ ? target.providerSpecificData+ : {};+ const existingPolicy =+ providerSpecificData.codexLimitPolicy &&+ typeof providerSpecificData.codexLimitPolicy === "object"+ ? providerSpecificData.codexLimitPolicy+ : {};++ const nextPolicy = {+ use5h: typeof existingPolicy.use5h === "boolean" ? existingPolicy.use5h : true,+ useWeekly: typeof existingPolicy.useWeekly === "boolean" ? existingPolicy.useWeekly : true,+ [field]: enabled,+ };++ const res = await fetch(`/api/providers/${connectionId}`, {+ method: "PUT",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ providerSpecificData: {+ ...providerSpecificData,+ codexLimitPolicy: nextPolicy,+ },+ }),+ });++ if (res.ok) {+ setConnections((prev) =>+ prev.map((connection) =>+ connection.id === connectionId+ ? {+ ...connection,+ providerSpecificData: {+ ...(connection.providerSpecificData || {}),+ codexLimitPolicy: nextPolicy,+ },+ }+ : connection+ )+ );+ }+ } catch (error) {+ console.error("Error toggling Codex quota policy:", error);+ }+ };+const handleRetestConnection = async (connectionId) => {if (!connectionId || retestingId) return;setRetestingId(connectionId);@@ -941,6 +993,11 @@ export default function ProviderDetailPage() {onMoveDown={() => handleSwapPriority(conn, connections[index + 1])}onToggleActive={(isActive) => handleUpdateConnectionStatus(conn.id, isActive)}onToggleRateLimit={(enabled) => handleToggleRateLimit(conn.id, enabled)}+ isCodex={providerId === "codex"}+ onToggleCodex5h={(enabled) => handleToggleCodexLimit(conn.id, "use5h", enabled)}+ onToggleCodexWeekly={(enabled) =>+ handleToggleCodexLimit(conn.id, "useWeekly", enabled)+ }onRetest={() => handleRetestConnection(conn.id)}isRetesting={retestingId === conn.id}onEdit={() => {@@ -2175,12 +2232,15 @@ function getStatusPresentation(connection, effectiveStatus, isCooldown, t) {function ConnectionRow({connection,isOAuth,+ isCodex,isFirst,isLast,onMoveUp,onMoveDown,onToggleActive,onToggleRateLimit,+ onToggleCodex5h,+ onToggleCodexWeekly,onRetest,isRetesting,onEdit,@@ -2242,6 +2302,16 @@ function ConnectionRow({const statusPresentation = getStatusPresentation(connection, effectiveStatus, isCooldown, t);const rateLimitEnabled = !!connection.rateLimitProtection;+ const codexPolicy =+ connection.providerSpecificData &&+ typeof connection.providerSpecificData === "object" &&+ connection.providerSpecificData.codexLimitPolicy &&+ typeof connection.providerSpecificData.codexLimitPolicy === "object"+ ? connection.providerSpecificData.codexLimitPolicy+ : {};+ const codex5hEnabled = typeof codexPolicy.use5h === "boolean" ? codexPolicy.use5h : true;+ const codexWeeklyEnabled =+ typeof codexPolicy.useWeekly === "boolean" ? codexPolicy.useWeekly : true;return (<div@@ -2331,6 +2401,35 @@ function ConnectionRow({<span className="material-symbols-outlined text-[13px]">shield</span>{rateLimitEnabled ? t("rateLimitProtected") : t("rateLimitUnprotected")}</button>+ {isCodex && (+ <>+ <span className="text-text-muted/30 select-none">|</span>+ <button+ onClick={() => onToggleCodex5h?.(!codex5hEnabled)}+ className={`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium transition-all cursor-pointer ${+ codex5hEnabled+ ? "bg-blue-500/15 text-blue-500 hover:bg-blue-500/25"+ : "bg-black/[0.03] dark:bg-white/[0.03] text-text-muted/50 hover:text-text-muted hover:bg-black/[0.06] dark:hover:bg-white/[0.06]"+ }`}+ title="Toggle Codex 5h limit policy"+ >+ <span className="material-symbols-outlined text-[13px]">timer</span>+ 5h {codex5hEnabled ? "ON" : "OFF"}+ </button>+ <button+ onClick={() => onToggleCodexWeekly?.(!codexWeeklyEnabled)}+ className={`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium transition-all cursor-pointer ${+ codexWeeklyEnabled+ ? "bg-violet-500/15 text-violet-500 hover:bg-violet-500/25"+ : "bg-black/[0.03] dark:bg-white/[0.03] text-text-muted/50 hover:text-text-muted hover:bg-black/[0.06] dark:hover:bg-white/[0.06]"+ }`}+ title="Toggle Codex weekly limit policy"+ >+ <span className="material-symbols-outlined text-[13px]">date_range</span>+ Weekly {codexWeeklyEnabled ? "ON" : "OFF"}+ </button>+ </>+ )}{hasProxy &&(() => {const colorClass =@@ -2451,14 +2550,18 @@ ConnectionRow.propTypes = {lastErrorSource: PropTypes.string,errorCode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),globalPriority: PropTypes.number,+ providerSpecificData: PropTypes.object,}).isRequired,isOAuth: PropTypes.bool.isRequired,+ isCodex: PropTypes.bool,isFirst: PropTypes.bool.isRequired,isLast: PropTypes.bool.isRequired,onMoveUp: PropTypes.func.isRequired,onMoveDown: PropTypes.func.isRequired,onToggleActive: PropTypes.func.isRequired,onToggleRateLimit: PropTypes.func.isRequired,+ onToggleCodex5h: PropTypes.func,+ onToggleCodexWeekly: PropTypes.func,onRetest: PropTypes.func.isRequired,isRetesting: PropTypes.bool,onEdit: PropTypes.func.isRequired,diff --git a/src/app/api/providers/[id]/route.ts b/src/app/api/providers/[id]/route.tsindex 8e92b8dbaf..6d91e3f3f1 100644--- a/src/app/api/providers/[id]/route.ts+++ b/src/app/api/providers/[id]/route.ts@@ -10,6 +10,30 @@ import { syncToCloud } from "@/lib/cloudSync";import { updateProviderConnectionSchema } from "@/shared/validation/schemas";import { isValidationFailure, validateBody } from "@/shared/validation/helpers";+function normalizeCodexLimitPolicy(+ incoming: unknown,+ existing: unknown+): { use5h: boolean; useWeekly: boolean } {+ const incomingRecord =+ incoming && typeof incoming === "object" && !Array.isArray(incoming)+ ? (incoming as Record<string, unknown>)+ : {};+ const existingRecord =+ existing && typeof existing === "object" && !Array.isArray(existing)+ ? (existing as Record<string, unknown>)+ : {};++ const existingUse5h = typeof existingRecord.use5h === "boolean" ? existingRecord.use5h : true;+ const existingUseWeekly =+ typeof existingRecord.useWeekly === "boolean" ? existingRecord.useWeekly : true;++ return {+ use5h: typeof incomingRecord.use5h === "boolean" ? incomingRecord.use5h : existingUse5h,+ useWeekly:+ typeof incomingRecord.useWeekly === "boolean" ? incomingRecord.useWeekly : existingUseWeekly,+ };+}+// GET /api/providers/[id] - Get single connectionexport async function GET(request: Request, { params }: { params: Promise<{ id: string }> }) {try {@@ -105,7 +129,20 @@ export async function PUT(request: Request, { params }: { params: Promise<{ id:existing.providerSpecificData && typeof existing.providerSpecificData === "object"? existing.providerSpecificData: {};- updateData.providerSpecificData = { ...existingPsd, ...incomingPsd };+ const mergedPsd = { ...existingPsd, ...incomingPsd };++ // Deep-merge and normalize Codex limit policy defaults.+ if (existing.provider === "codex") {+ const incomingRecord = incomingPsd as Record<string, unknown>;+ if ("codexLimitPolicy" in incomingRecord || "codexLimitPolicy" in existingPsd) {+ mergedPsd.codexLimitPolicy = normalizeCodexLimitPolicy(+ incomingRecord.codexLimitPolicy,+ (existingPsd as Record<string, unknown>).codexLimitPolicy+ );+ }+ }++ updateData.providerSpecificData = mergedPsd;}const updated = await updateProviderConnection(id, updateData);diff --git a/src/domain/quotaCache.ts b/src/domain/quotaCache.tsindex 4111e202de..30df9c8852 100644--- a/src/domain/quotaCache.ts+++ b/src/domain/quotaCache.ts@@ -35,6 +35,13 @@ interface QuotaCacheEntry {windowDurationMs?: number | null; // T08: optional rolling window duration}+interface QuotaWindowStatus {+ remainingPercentage: number;+ usedPercentage: number;+ resetAt: string | null;+ reachedThreshold: boolean;+}+// ─── Constants ──────────────────────────────────────────────────────────────const ACTIVE_TTL_MS = 5 * 60 * 1000; // 5 minutes for active accounts@@ -89,6 +96,11 @@ function parseDate(value: string): number | null {return Number.isNaN(ms) ? null : ms;}+function clampPercent(value: number): number {+ if (!Number.isFinite(value)) return 0;+ return Math.max(0, Math.min(100, value));+}+function earliestResetAt(quotas: Record<string, QuotaInfo>): string | null {let earliest: string | null = null;let earliestMs = Infinity;@@ -175,6 +187,46 @@ export function isAccountQuotaExhausted(connectionId: string): boolean {return true;}+/**+ * Return quota window status for a connection (e.g., session/weekly).+ * Returns null when no cache or no window data is available.+ */+export function getQuotaWindowStatus(+ connectionId: string,+ windowName: string,+ thresholdPercent = 90+): QuotaWindowStatus | null {+ const entry = cache.get(connectionId);+ if (!entry) return null;++ const now = Date.now();+ const advanced = advancedWindowResetAt(entry, now);+ if (advanced) {+ entry.exhausted = false;+ }++ const window = entry.quotas[windowName];+ if (!window) return null;++ const remainingPercentage = clampPercent(window.remainingPercentage);+ const usedPercentage = clampPercent(100 - remainingPercentage);++ let resetAt = window.resetAt || null;+ if (resetAt) {+ const resetMs = parseDate(resetAt);+ if (resetMs !== null && resetMs <= now) {+ resetAt = null;+ }+ }++ return {+ remainingPercentage,+ usedPercentage,+ resetAt,+ reachedThreshold: usedPercentage >= thresholdPercent,+ };+}+/*** Mark an account as quota-exhausted from a 429 response (no quota data available).* Uses 5-minute fixed TTL since we don't know the actual resetAt.diff --git a/src/sse/services/auth.ts b/src/sse/services/auth.tsindex badcf451c3..c431c2952e 100644--- a/src/sse/services/auth.ts+++ b/src/sse/services/auth.ts@@ -4,7 +4,7 @@ import {updateProviderConnection,getSettings,} from "@/lib/localDb";-import { isAccountQuotaExhausted } from "@/domain/quotaCache";+import { getQuotaWindowStatus, isAccountQuotaExhausted } from "@/domain/quotaCache";import {isAccountUnavailable,getUnavailableUntil,@@ -79,6 +79,28 @@ function toProviderConnection(value: unknown): ProviderConnectionView {};}+function toBooleanOrDefault(value: unknown, fallback: boolean): boolean {+ return typeof value === "boolean" ? value : fallback;+}++function getCodexLimitPolicy(providerSpecificData: JsonRecord): {+ use5h: boolean;+ useWeekly: boolean;+} {+ const policy = asRecord(providerSpecificData.codexLimitPolicy);+ return {+ use5h: toBooleanOrDefault(policy.use5h, true),+ useWeekly: toBooleanOrDefault(policy.useWeekly, true),+ };+}++function parseFutureDateMs(value: string | null): number | null {+ if (!value) return null;+ const ms = new Date(value).getTime();+ if (!Number.isFinite(ms) || ms <= Date.now()) return null;+ return ms;+}+// Mutex to prevent race conditions during account selectionlet selectionMutex = Promise.resolve();@@ -198,11 +220,91 @@ export async function getProviderCredentials(return null;}+ let policyEligibleConnections = availableConnections;+ if (provider === "codex") {+ const blockedByPolicy: Array<{+ id: string;+ reasons: string[];+ resetAt: string | null;+ }> = [];++ policyEligibleConnections = availableConnections.filter((connection) => {+ const policy = getCodexLimitPolicy(connection.providerSpecificData);+ const sessionStatus = policy.use5h+ ? getQuotaWindowStatus(connection.id, "session", 90)+ : null;+ const weeklyStatus = policy.useWeekly+ ? getQuotaWindowStatus(connection.id, "weekly", 90)+ : null;++ const reasons: string[] = [];+ const resetCandidates: Array<string | null> = [];++ if (policy.use5h && sessionStatus?.reachedThreshold) {+ reasons.push(`5h usage ${Math.round(sessionStatus.usedPercentage)}%`);+ resetCandidates.push(sessionStatus.resetAt);+ }++ if (policy.useWeekly && weeklyStatus?.reachedThreshold) {+ reasons.push(`weekly usage ${Math.round(weeklyStatus.usedPercentage)}%`);+ resetCandidates.push(weeklyStatus.resetAt);+ }++ if (reasons.length > 0) {+ const nextResetAt =+ resetCandidates+ .map((candidate) => ({+ raw: candidate,+ ms: parseFutureDateMs(candidate),+ }))+ .filter((entry) => entry.ms !== null)+ .sort((a, b) => (a.ms as number) - (b.ms as number))[0]?.raw || null;++ blockedByPolicy.push({+ id: connection.id,+ reasons,+ resetAt: nextResetAt,+ });+ return false;+ }++ return true;+ });++ if (blockedByPolicy.length > 0) {+ log.info(+ "AUTH",+ `${provider} | quota policy filtered ${blockedByPolicy.length} account(s): ${blockedByPolicy+ .map((entry) => `${entry.id.slice(0, 8)}(${entry.reasons.join(", ")})`)+ .join("; ")}`+ );+ }++ if (policyEligibleConnections.length === 0 && availableConnections.length > 0) {+ const earliestResetMs = blockedByPolicy+ .map((entry) => parseFutureDateMs(entry.resetAt))+ .filter((ms): ms is number => ms !== null)+ .sort((a, b) => a - b)[0];++ const retryAfter = earliestResetMs+ ? new Date(earliestResetMs).toISOString()+ : new Date(Date.now() + 5 * 60 * 1000).toISOString();++ return {+ allRateLimited: true,+ retryAfter,+ retryAfterHuman: formatRetryAfter(retryAfter),+ lastError: "All Codex accounts reached configured quota threshold",+ lastErrorCode: 429,+ };+ }+ }+// Quota-aware: prioritize accounts with available quota- const withQuota = availableConnections.filter((c) => !isAccountQuotaExhausted(c.id));- const exhaustedQuota = availableConnections.filter((c) => isAccountQuotaExhausted(c.id));+ const withQuota = policyEligibleConnections.filter((c) => !isAccountQuotaExhausted(c.id));+ const exhaustedQuota = policyEligibleConnections.filter((c) => isAccountQuotaExhausted(c.id));const orderedConnections =- withQuota.length > 0 ? [...withQuota, ...exhaustedQuota] : availableConnections;+ withQuota.length > 0 ? [...withQuota, ...exhaustedQuota] : policyEligibleConnections;if (exhaustedQuota.length > 0) {log.debug(