feat: model-level backoff instead of provider-level#4928
feat: model-level backoff instead of provider-level#4928alex-solovyev wants to merge 1 commit intomainfrom
Conversation
Backoff was keyed on provider name — when sonnet hit a rate limit, all anthropic models (including opus) were backed off together. Same-provider model fallback didn't work. Changes: - provider_backoff table: PK changed from provider to model (full provider/model string). DROP+CREATE migration (backoff rows are ephemeral, 15-60 min TTL). - record_provider_backoff(): accepts model ID, extracts provider - model_backoff_active(): checks model-level first, then falls back to provider-level for auth_error (auth is shared per provider) - choose_model(): passes model to backoff check, not provider - cmd_backoff(): status/clear/set work with model IDs - provider_backoff_active() kept as backward-compatible alias Auth errors still block all models of the same provider — OpenCode uses one OAuth token / API key per provider, no multi-account. Closes #4925
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Caution Review failedPull request was closed or merged during review WalkthroughRefactored backoff tracking in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Problem
AIDEVOPS_HEADLESS_MODELS="anthropic/claude-sonnet-4-6,anthropic/claude-opus-4-6"When sonnet gets rate-limited (429), the entire
anthropicprovider was backed off. Opus was skipped too, even though it has its own separate rate limit. Same-provider fallback didn't work.Changes
Schema migration (
init_state_db)provider_backofftable: PK changed fromprovidertomodel(fullprovider/modelstring)providercolumn for provider-level auth_error lookupsDROP TABLE + CREATEmigration — backoff rows are ephemeral (15-60 min TTL), no data lossmodel_backoff_active()(new, replacesprovider_backoff_active)WHERE model = ?)WHERE provider = ? AND reason = 'auth_error')provider_backoff_active()kept as backward-compatible aliasrecord_provider_backoff()anthropic/claude-sonnet-4-6), extracts provider internallychoose_model()model_backoff_active(), not just provider namecmd_backoff()status: shows model columnclear: accepts model ID or provider name (clears accordingly)set: accepts model IDBehaviour matrix
Verification
bash -n: passshellcheck: clean (SC1091 info only)Note from maintainer
OpenAI already removed from
DEFAULT_HEADLESS_MODELSin a prior commit. No change needed.Closes #4925
Summary by CodeRabbit
Refactor
Documentation