fix(github-copilot): surface quota exhaustion 429 instead of retrying#13584
Merged
Innei merged 1 commit intolobehub:canaryfrom Apr 7, 2026
Merged
Conversation
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
|
@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. |
Member
|
Assigning reviewers based on the changed file cc @Innei @hezhijie0327 @arvinxx — this touches the GitHub Copilot provider's retry/rate-limit logic. |
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13572
Problem
executeWithRetryinpackages/model-runtime/src/providers/githubCopilot/index.tsreads theRetry-Afterheader correctly, but caps the delay at 10 seconds viaMath.min(retryAfter, 10_000). When GitHub Copilot returns a 429 for quota exhaustion with aRetry-Afterof several hours, the client silently caps it to 10s and retries up toMAX_RATE_LIMIT_RETRIEStimes — consuming all retry budget without surfacing the real error to the user.Solution
Added a
QUOTA_EXHAUSTION_THRESHOLD_MSconstant (5 minutes). Before waiting to retry, we check if the parsedretry-afterexceeds this threshold. If it does, we throw immediately (viamapError) instead of waiting and retrying, so the user sees the quota exhaustion error right away.Testing