#13077: fix: prevent cooldown pollution across different models on the same provider
agents
stale
Cluster:
Model Cooldown Management
## Summary
When model fallback iterates candidates on the same provider but different models (e.g. Claude → Gemini on google-antigravity), cooldown set by the first model incorrectly blocks attempts with subsequent models. This happens because cooldown is tracked per-profile (not per-model), and the pre-flight check skips **all** candidates on a provider once any cooldown is active — even though different models may use entirely independent quota pools.
## Problem
```
Claude 4.6 rate-limited → profile enters cooldown
→ fallback to Gemini Pro (same provider) → cooldown check sees same profile in cooldown → skips
→ Gemini Pro quota is full but never tried
```
The same issue affects any provider with multiple model tiers (e.g. Flash ↔ Pro fallbacks).
## Fix
Track which providers have already been cooldown-checked during the fallback loop. Only perform the cooldown pre-check on the **first** candidate for each provider. Subsequent candidates on the same provider (with a different model) skip the pre-check and proceed to attempt execution directly.
This is the minimal, conservative fix — it doesn't alter cooldown state or profile tracking, just prevents the pre-flight check from blocking unrelated models.
## Test
Added test: `"does not skip different model on same provider due to cooldown from first model"` — verifies that when `provider/model-a` profiles are in cooldown, a fallback to `provider/model-b` is still attempted and succeeds.
All existing cooldown tests continue to pass (the cross-provider cooldown skip behavior is unchanged).
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR changes `runWithModelFallback` to avoid “cooldown pollution” when iterating multiple model candidates on the same provider by only performing the provider-wide cooldown pre-check once per provider, rather than once per candidate. It also adds a regression test to ensure a fallback to a different model on the same provider is still attempted.
The change fits into the existing model-fallback flow by adjusting the early “skip provider if all profiles are in cooldown” gate, without changing how failover errors are normalized/recorded, and without changing auth store semantics.
<h3>Confidence Score: 3/5</h3>
- This PR is directionally correct but may change runtime behavior in cases where a provider has no available profiles.
- The new provider-level cooldown check suppression can cause `params.run` to be called for models on a provider even when all profiles are still in cooldown, which can regress previous skip behavior depending on how credentials are selected. The added test currently doesn’t exercise real credential availability, so it may not protect against that regression.
- src/agents/model-fallback.ts, src/agents/model-fallback.test.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#20388: fix(failover): don't skip same-provider fallback models when cooldo...
by Limitless2023 · 2026-02-18
85.6%
#23816: fix(agents): model fallback skipped during session overrides and pr...
by ramezgaberiel · 2026-02-22
81.6%
#15881: fix(models): probe-safe cooldown handling and compatible fallback a...
by wboudy · 2026-02-14
81.6%
#14914: fix: resolve actual failure reason for cooldown-skipped providers
by mcaxtr · 2026-02-12
80.6%
#13188: fix: add cross-provider fallback when primary provider is rate-limited
by 1bcMax · 2026-02-10
79.9%
#16797: fix(auth-profiles): implement per-model rate limit cooldown tracking
by mulhamna · 2026-02-15
79.5%
#14824: fix: do not trigger provider cooldown on LLM request timeouts
by CyberSinister · 2026-02-12
79.5%
#18902: fix: exempt format errors from auth profile cooldown
by tag-assistant · 2026-02-17
78.9%
#22064: fix(failover): bypass models allowlist for configured fallback models
by winston-bepresent · 2026-02-20
78.6%
#11349: fix(agents): do not filter fallback models by models allowlist
by liuxiaopai-ai · 2026-02-07
78.0%