[Feature] Model fallback routing when all eligible accounts are quota-cooled for the requested model
想要什么,用来做什么 / What you want and what for
What I want & Use Case
In multi-account environments, high-tier models like gemini-4-hydrogen or gemini-4-neon occasionally exhaust daily tokens across all accounts (generate_content_tokens_per_model_per_user, limit: 10000000) with reset times of 20+ hours.
Currently, once all accounts are in cooldown for that specific model, requests immediately fail with 429 rate_limit_exceeded / AllCoolingError. This interrupts automated coding agents (e.g. OpenCode, DSH, Cursor, Claude Code), forcing the user to manually stop their work, open settings, and reconfigure model mappings.
Because other models (e.g. gemini-4-neon, gemini-3.8-flash, gemini-3.5-flash-lite) often still have full quota on those exact same accounts, having an optional model fallback configuration would ensure seamless, uninterrupted operation.
Proposed Solution
- Configuration (
MODEL_FALLBACKS): Allow defining fallback chains in.env/ Settings, e.g.:MODEL_FALLBACKS=gemini-4-hydrogen:gemini-4-neon,gemini-3.8-flash;gemini-4-neon:gemini-4-hydrogen,gemini-3.8-flash - Behavior in
generateWithRetry(internal/app/runtime.go): WhenacquireWarmLeaseconfirms all candidate accounts forselection.ModelIDare cooled down (AllCoolingErrorwhere earliest reset > 1 minute):- If a fallback model is configured and has available accounts, log an
INFOevent (模型额度耗尽,自动回退到 <fallback_model>) and switch the request target to the fallback model. - If no fallback model is configured or all fallback models are also exhausted, return
429 AllCoolingErroras usual.
- If a fallback model is configured and has available accounts, log an
版本 / Version
v0.3.13