Fix #762: Respect Retry-After and backoff for HTTP 429 (no-retry on CREDITS_EXHAUSTED)#881
Open
Sameer Kadam (Sameer6305) wants to merge 2 commits intobrowseros-ai:devfrom
Open
Conversation
Contributor
|
PR author is not in the allowed authors list. |
Contributor
|
All contributors have signed the CLA. Thank you! |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #762 by adding centralized, bounded HTTP retry behavior (exponential backoff + jitter) with proper Retry-After handling for 429s, and by marking CREDITS_EXHAUSTED as non-retryable to avoid pointless retries.
Changes:
- Added shared
HTTP_RETRYconfiguration and a reusablecreateRetryableFetchhelper withRetry-Afterparsing. - Integrated retry handling into
browseros-fetch.tsandopenrouter-fetch.ts, includingCREDITS_EXHAUSTEDhandling. - Added/updated tests and improved 429 user-facing messaging in
useOpenClaw.ts.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/browseros-agent/packages/shared/src/constants/timeouts.ts | Adds centralized HTTP retry configuration constants. |
| packages/browseros-agent/apps/server/src/lib/retry-handler.ts | Introduces the core retry wrapper with backoff + Retry-After support. |
| packages/browseros-agent/apps/server/src/lib/browseros-fetch.ts | Wraps BrowserOS gateway fetch with retry logic and credits-exhausted classification. |
| packages/browseros-agent/apps/server/src/lib/openrouter-fetch.ts | Wraps OpenRouter-compatible fetch with retry and enhanced APICallError construction. |
| packages/browseros-agent/apps/server/tests/lib/retry-handler.test.ts | Adds unit tests for retry handler behavior. |
| packages/browseros-agent/apps/server/tests/lib/browseros-fetch.test.ts | Adds integration tests for BrowserOS fetch retry/error behavior. |
| packages/browseros-agent/apps/agent/entrypoints/app/agents/useOpenClaw.ts | Improves 429 error messaging with Retry-After context. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Fixes HTTP 429 retry exhaustion by replacing immediate retries with bounded exponential backoff and proper
Retry-Afterhandling.Changes
Added centralized retry handler with:
Retry-Afterparsing (RFC 7231)Integrated retry handling into:
browseros-fetch.tsopenrouter-fetch.tsMarked
CREDITS_EXHAUSTEDresponses as non-retryable.Added tests covering:
Improved client-side 429 messaging in
useOpenClaw.ts.Notes
HTTP_RETRY.MAX_RETRIES.Retry-Afterheaders take precedence when present.Validation
Closes #762