Skip to content

fix: retry cloud model catalog sync when first account becomes active#206

Open
clarezoe wants to merge 1 commit into
dwgx:masterfrom
Fei2-Labs:fix/model-catalog-sync-on-active
Open

fix: retry cloud model catalog sync when first account becomes active#206
clarezoe wants to merge 1 commit into
dwgx:masterfrom
Fei2-Labs:fix/model-catalog-sync-on-active

Conversation

@clarezoe

@clarezoe clarezoe commented Jul 3, 2026

Copy link
Copy Markdown

Problem

fetchAndMergeModelCatalog() was only called once at startup. If no active account existed at that moment, the cloud catalog sync was skipped entirely and never retried — meaning newly available upstream models (e.g. Claude Fable 5, redeployed 2026-07-01) wouldn't appear in /v1/models until a manual restart with an already-active account.

Root Cause

In src/auth.js, fetchAndMergeModelCatalog() runs once during initAuth(). It finds the first active account and, if none exists, logs 'No active account for model catalog fetch' and returns. There is no retry path — accounts added later never trigger a re-sync.

Fix

Add a _modelCatalogSynced flag and a trySyncModelCatalog() fire-and-forget wrapper that coalesces concurrent calls. Call it from every account activation path:

  • addAccountByKey — adding API key account
  • addAccountByToken — adding token account
  • addAccountByEmail — email login
  • setAccountStatus(id, 'active') — manual status change
  • resetAccountErrors — error reset recovery
  • reportSuccess — auto-recovery on successful request
  • maybeRecoverErrorAccount — half-open recovery

trySyncModelCatalog() checks:

  1. If sync already succeeded (_modelCatalogSynced) → skip
  2. If a sync is already in flight (_modelCatalogSyncPromise) → skip
  3. If no active account exists → skip
  4. Otherwise → fire fetchAndMergeModelCatalog() in the background

Verification

Tested on production deployment. After restart with no active accounts at startup, adding the first account triggered the sync automatically:

Model catalog: 150 cloud models, 45 new entries merged

Claude Fable 5 variants (claude-5-fable-low/medium/high/xhigh/max) now appear in /v1/models.

fetchAndMergeModelCatalog() was only called once at startup. If no active
account existed at that moment, the cloud catalog sync was skipped entirely
and never retried — meaning newly available upstream models (e.g. Claude
Fable 5) wouldn't appear in /v1/models until a manual restart with an
already-active account.

Add _modelCatalogSynced flag + trySyncModelCatalog() fire-and-forget
wrapper that coalesces concurrent calls. Call it from every account
activation path: addAccountByKey, addAccountByToken, addAccountByEmail,
setAccountStatus, resetAccountErrors, reportSuccess, and
maybeRecoverErrorAccount.

Co-Authored-By: Oz <oz-agent@warp.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants