Let users configure where failover goes (and come back afterwards)
What I'd like
A way to control where a session goes when its provider hits a rate limit, and to have it come back afterwards.
How it works today (v0.98.1, cb2895a)
When a provider runs out, jcode picks a new route and resends. There are two paths:
- Automatic (countdown): only when the failing account is in the auto-switch pool. Candidates are ordered by position in
~/.jcode/account-pool.json(model_context.rs). That file can be hand-edited to reorder accounts or add an API-key account, but I couldn't find it documented anywhere. - Otherwise: jcode offers the next-best route (Ctrl+Y to accept) from a static provider order,
fallback_sequence.
What can't be configured, as far as I can tell:
- Which model is used on the new account. It's the first eligible one in catalog order. The curated ranking only decides eligibility (here). The
[provider]config has no failover target or fallback list; onlycross_provider_failoverandsame_provider_account_failover. - Which models are eligible. It's a fixed list per provider. For example, Antigravity only considers Gemini models.
- Returning afterwards. I found no code that moves a session back once the original provider's limit resets.
- Per-session settings. Everything is global.
Example
My setup is OpenAI (GPT-6 Luna, xhigh), Claude, Antigravity and an OpenRouter key. If OpenAI and Claude both run out, the session moves to Antigravity's gemini-3-flash, because it's listed before gemini-2.5-pro. I can add the OpenRouter key to the pool, but then I get the first eligible OpenRouter route in catalog order, not a model I choose. (I worked this out from the code and jcode model list -p antigravity; I haven't captured it live.)
For a quick interactive session that's fine. For a long or unattended one, the rest of the work quietly continues on a much lighter model. Today the only fix is to switch it manually with /model.
Suggestion
- Let me list the fallback targets myself, in order:
[provider] failover_routes = ["claude-oauth:claude-opus-4-8", "openrouter:meta/muse-spark-1.3-contributor"] - When nothing is configured, choose by model ranking instead of catalog order, ideally something close to the model that failed.
- Optionally, switch back once the original provider resets.
- Allow per-session overrides.
Related
- #1130, #1612 and PRs #1270, #1613: failover between accounts of the same provider. This issue is about the model and provider chosen when moving across providers.
- #1497: ordered fallbacks for swarm worker lanes. Its text mentions
provider.quota_fallback, which I couldn't find in the code onmaster. - #865: model-routing RFC (vision, per-tool, per-role). It doesn't cover rate-limit failover.
- #950: picking the initial provider by remaining quota.
Thanks for the thorough analysis. Configurable failover targets, ranking-based selection and return-after-reset are product design decisions, so I've flagged this for the maintainer.
— Jcode agent (automated triage), on behalf of @1jehuang