[Bug] PlanLimitKind (套餐限额) 429 cooldowns bypass RejectedSize throttling, Fallback backoff, and MAX_ACCOUNT_SWITCHES under IgnoreQuotaCooldown
发生了什么 / What happened
Summary
When all eligible accounts for a model enter PlanLimitKind (套餐限额, e.g., HTTP 429, code 8: You've reached your usage limit for this model (resets in 9 hours, 28 minutes)), acquireWarmLease enables IgnoreQuotaCooldown. Because PlanLimitKind neither records RejectedSize/RejectedUntil nor triggers Fallback backoff and skips MAX_ACCOUNT_SWITCHES, every subsequent request re-probes all cooled accounts sequentially (~40–50s per request) even for identical ~175 KB prompts seconds apart.
Environment
- OS / Runtime: Windows 11 amd64 (Desktop binary)
- Version:
v0.3.13(c77dd89) WAA_BACKEND:camoufox- Relevant config:
ROUTING_STRATEGY=round-robin,MAX_ACCOUNT_SWITCHES=5,MODEL_CHANNELS=gemini-4-neon:playground, 9 Pro accounts eligible forgemini-4-neon
Observed Behavior (with sanitized logs)
- While at least one non-cooled Pro account exists (e.g.,
account_i), requests go exclusively toaccount_iand never touch the other 8 cooled accounts (19 consecutive200 OKresponses). - At
01:46:40,account_ihits429:AI Studio GenerateContent returned HTTP 429, protocol error code 8: You've reached your usage limit for this model (resets in 9 hours, 13 minutes)and receivesCooldowns["gemini-4-neon"]until10:59:40(07:59:40Z) inruntime-state.json. - Once all 9 Pro accounts are in
PlanLimitKindcooldown, every incominggemini-4-neonrequest sequentially probes all 9 accounts (~42–48s each,429 ×8/429 ×9), includingaccount_iwhich was never deleted or modified:
{"time":"2026-11-21T01:46:40+03:00","level":"WARN","msg":"账号冷却","event":"request.progress","source":"account_i","kind":"套餐限额","scope":"gemini-4-neon","until":"2026-11-21T10:59:40+03:00"}
{"time":"2026-11-21T01:50:46+03:00","level":"WARN","msg":"账号冷却","event":"request.progress","source":"account_i","kind":"套餐限额","scope":"gemini-4-neon","until":"2026-11-21T10:59:46+03:00"}
{"time":"2026-11-21T01:51:48+03:00","level":"WARN","msg":"账号冷却","event":"request.progress","source":"account_i","kind":"套餐限额","scope":"gemini-4-neon","until":"2026-11-21T10:59:48+03:00"}
Between 01:50:41 and 02:01:00 (all with ~175 KB input prompts), account_i and all other 8 already-cooled accounts were re-probed on every request (01:50:41, 01:51:38, 01:55:12, 01:57:30, 01:58:05, 01:58:54, 02:00:17), taking 42–48s per failure.
Also note a minor side effect in those logs: because Google reports "resets in X hours, Y minutes" rounded down to minutes, now.Add(reset) jitters by ±59s across retries; whenever next.Until lands a few seconds later than base.Until, MarkQuotaCooldownIfGeneration sees next.Until.After(base.Until) (true), re-writes runtime-state.json, and emits duplicate 账号冷却 warnings for the exact same quota reset window.
Expected Behavior
Per docs/development.md, quota-cooled fallback exists because shorter requests may still succeed; accounts that just rejected an equal/larger payload (or repeatedly return 429 during fallback probing) should be throttled via RejectedSize/Fallback backoff, and total fallback probes per request should be bounded so AllCoolingError (429) returns quickly instead of looping through all N accounts on every request.
Root Cause Pointers (verified in v0.3.13 / c77dd89)
RejectedSize is only saved for DailyLimitKind, not PlanLimitKind (internal/aistudio/accounts.go, MarkQuotaCooldownIfGeneration): if strings.HasPrefix(cooldown.Reason, DailyLimitKind) && cooldown.RequestSize > 0 skips PlanLimitKind (套餐限额). Meanwhile selectionCooldown checks RequestQuotaCooldown(cooldown.Reason) (both DailyLimitKind and PlanLimitKind), so PlanLimitKind is ignored by IgnoreQuotaCooldown while never getting RejectedSize / RejectedUntil protection.
Fallback escalation never triggers for repeated PlanLimitKind 429s (internal/aistudio/accounts.go, MarkQuotaCooldownIfGeneration): layered := exists && previous.Active(now) && RequestQuotaCooldown(previous.Reason) && !RequestQuotaCooldown(cooldown.Reason) is false when an account already in PlanLimitKind fails again with PlanLimitKind.
As a result, previous.Fallback remains nil, and there is zero escalating backoff (1m -> 5m -> 15m -> 30m -> 1h) during IgnoreQuotaCooldown.
Unbounded switching through all accounts (internal/app/runtime.go, generateWithRetry & settleAttempt): retry.maxAttempts is set to len(EnabledAccounts()), and settleAttempt only increments retry.failures++ when !quotaFailure, so MAX_ACCOUNT_SWITCHES does not apply and every request probes all N accounts sequentially (~5s × N on Camoufox).
Suggested Fix Direction
Record RejectedSize / RejectedUntil for RequestQuotaCooldown(cooldown.Reason) (both DailyLimitKind and PlanLimitKind), not only DailyLimitKind. When an account already in RequestQuotaCooldown is probed via IgnoreQuotaCooldown and fails again with RequestQuotaCooldown (for >= RejectedSize or after a failed fallback probe), apply escalating Fallback backoff (planLimitBackoff: 1m -> 5m -> 15m -> 30m -> 1h) on previous.Fallback while keeping the underlying Until intact — so all-cooled requests immediately return AllCoolingError (429) during the backoff window instead of spending 45s probing all N accounts. Code block
版本 / Version
v0.3.13