#1145·superagent

providers/index.ts — 429 triggers instant fallback with no Retry-After consulted

Author: SirBrentonCreated May 10, 2026Updated Jun 4, 2026
Labelsbug

Finding

sdk/typescript/src/providers/index.ts — callProvider() receives a 429 and immediately calls the fallback model with no delay and no Retry-After consulted.

typescript
if (RETRYABLE_STATUS_CODES.includes(response.status)) {
  return callProvider(fallbackModelString, ...);
}

The consequence

Under concurrent load, the same burst that rate-limited the primary model hits the fallback immediately. Both models end up rate-limited.

This misclassifies a WAIT signal as a STOP — the 429 means “wait and retry,” not “abandon this model permanently.” Routing to fallback immediately burns fallback capacity on requests that should have waited.

Expected behavior

  • Read Retry-After when present before routing to fallback
  • If Retry-After is short: wait, then retry primary
  • If Retry-After is long: route to fallback
  • Do not route to fallback instantly on every 429

Suggested fix shape

typescript
if (response.status === 429) {
  const retryAfter = response.headers?.get('retry-after');
  if (retryAfter) {
    const delay = parseInt(retryAfter, 10) * 1000;
    if (delay < FALLBACK_THRESHOLD_MS) {
      await sleep(delay);
      return callProvider(modelString, ...); // retry primary
    }
  }
  // Long or missing Retry-After — use fallback
  return callProvider(fallbackModelString, ...);
}

Related pattern

blocked-failover-wait-treated-as-stop

Corpus reference: https://github.com/SirBrenton/pitstop-truth

Source: superagent-ai/superagent