Skip to content

fix(github-copilot): surface quota exhaustion 429 instead of retrying#13584

Merged
Innei merged 1 commit intolobehub:canaryfrom
octo-patch:fix/issue-13572-429-quota-exhaustion-stop-retry
Apr 7, 2026
Merged

fix(github-copilot): surface quota exhaustion 429 instead of retrying#13584
Innei merged 1 commit intolobehub:canaryfrom
octo-patch:fix/issue-13572-429-quota-exhaustion-stop-retry

Conversation

@octo-patch
Copy link
Copy Markdown
Contributor

Fixes #13572

Problem

executeWithRetry in packages/model-runtime/src/providers/githubCopilot/index.ts reads the Retry-After header correctly, but caps the delay at 10 seconds via Math.min(retryAfter, 10_000). When GitHub Copilot returns a 429 for quota exhaustion with a Retry-After of several hours, the client silently caps it to 10s and retries up to MAX_RATE_LIMIT_RETRIES times — consuming all retry budget without surfacing the real error to the user.

Solution

Added a QUOTA_EXHAUSTION_THRESHOLD_MS constant (5 minutes). Before waiting to retry, we check if the parsed retry-after exceeds this threshold. If it does, we throw immediately (via mapError) instead of waiting and retrying, so the user sees the quota exhaustion error right away.

const QUOTA_EXHAUSTION_THRESHOLD_MS = 5 * 60 * 1000; // 5 minutes

// If retry-after exceeds the quota exhaustion threshold, surface immediately
if (retryAfter > QUOTA_EXHAUSTION_THRESHOLD_MS) {
  throw this.mapError(error);
}

Testing

  • Static analysis: verified the changed path handles quota-exhaustion 429 (retry-after > 5 min) by throwing immediately
  • Transient rate limits (retry-after ≤ 5 min) still go through the existing exponential backoff path unchanged

When the GitHub Copilot API returns a 429 with a Retry-After header
exceeding 5 minutes (indicating quota exhaustion rather than transient
rate limiting), throw the error immediately instead of retrying up to
MAX_RATE_LIMIT_RETRIES times with a silently capped 10s delay.

Fixes lobehub#13572
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 5, 2026

@octo-patch is attempting to deploy a commit to the LobeHub OSS Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@lobehubbot
Copy link
Copy Markdown
Member

Assigning reviewers based on the changed file packages/model-runtime/src/providers/githubCopilot/index.ts.

cc @Innei @hezhijie0327 @arvinxx — this touches the GitHub Copilot provider's retry/rate-limit logic.

@Innei Innei merged commit 496b10f into lobehub:canary Apr 7, 2026
4 of 5 checks passed
@lobehubbot
Copy link
Copy Markdown
Member

❤️ Great PR @octo-patch ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.

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.

429 retry-after capped at 10s — quota exhaustion retried instead of surfaced

3 participants