Skip to content

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
Sameer6305:fix/http-429-retry-handling
Open

Fix #762: Respect Retry-After and backoff for HTTP 429 (no-retry on CREDITS_EXHAUSTED)#881
Sameer Kadam (Sameer6305) wants to merge 2 commits intobrowseros-ai:devfrom
Sameer6305:fix/http-429-retry-handling

Conversation

@Sameer6305
Copy link
Copy Markdown

Summary

Fixes HTTP 429 retry exhaustion by replacing immediate retries with bounded exponential backoff and proper Retry-After handling.

Changes

  • Added centralized retry handler with:

    • exponential backoff
    • jitter
    • bounded retries
    • Retry-After parsing (RFC 7231)
    • retryable/non-retryable classification
  • Integrated retry handling into:

    • browseros-fetch.ts
    • openrouter-fetch.ts
  • Marked CREDITS_EXHAUSTED responses as non-retryable.

  • Added tests covering:

    • retry behavior
    • Retry-After handling
    • bounded retries
    • non-retryable 429 cases
  • Improved client-side 429 messaging in useOpenClaw.ts.

Notes

Validation

Closes #762

Copilot AI review requested due to automatic review settings April 30, 2026 12:30
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

PR author is not in the allowed authors list.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

All contributors have signed the CLA. Thank you!
Posted by the CLA Assistant Lite bot.

@Sameer6305
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@Sameer6305
Copy link
Copy Markdown
Author

recheck

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_RETRY configuration and a reusable createRetryableFetch helper with Retry-After parsing.
  • Integrated retry handling into browseros-fetch.ts and openrouter-fetch.ts, including CREDITS_EXHAUSTED handling.
  • 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.

Comment thread packages/browseros-agent/apps/server/src/lib/retry-handler.ts
Comment thread packages/browseros-agent/apps/server/src/lib/retry-handler.ts
Comment thread packages/browseros-agent/apps/server/src/lib/openrouter-fetch.ts
Comment thread packages/browseros-agent/apps/server/src/lib/openrouter-fetch.ts
Comment thread packages/browseros-agent/apps/server/tests/lib/browseros-fetch.test.ts Outdated
Comment thread packages/browseros-agent/apps/agent/entrypoints/app/agents/useOpenClaw.ts Outdated
Comment thread packages/browseros-agent/apps/server/src/lib/retry-handler.ts Outdated
Comment thread packages/browseros-agent/apps/server/src/lib/retry-handler.ts Outdated
Comment thread packages/browseros-agent/apps/server/src/lib/retry-handler.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

HTTP 429 Too Many Requests: agent fails after 3 retry attempts

2 participants