Skip to content

Conversation

@jcbdev
Copy link
Contributor

@jcbdev jcbdev commented Feb 10, 2025

Description

OpenRouter requests often fail NOT because the completion endpoint has failed but because it performs a follow call to the generation API for the usage stats which only waits for 500ms before the call. It then throws an error if the "generation" is unavailable which from a lot of providers takes more than 500ms after the completion is finished to be available on the endpoint. This adds some code to retry 3 times to make it more likely to succeed.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Tested with deepseek and google gemini models on openrouter.

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Additional context

Related Issues

Reviewers


Important

Adds retry logic to OpenRouter generation endpoint in openrouter.ts to improve reliability by retrying up to 3 times with a delay.

  • Behavior:
    • Adds retry logic to OpenRouter generation endpoint in openrouter.ts.
    • Retries up to 3 times with a 500ms delay between attempts if the generation endpoint is unavailable.
  • Misc:
    • Logs errors to console if fetching generation details fails.

This description was created by Ellipsis for 9c480aa. It will automatically update as commits are pushed.

…slow usage stat updates server side

Signed-off-by: James Barker <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2025

⚠️ No Changeset found

Latest commit: b85960b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

…of retries and delay as the glama provider (for consistency)

Signed-off-by: James Barker <[email protected]>
Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

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

Thank you!

@mrubens mrubens merged commit 059de0f into RooCodeInc:main Feb 10, 2025
6 checks passed
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.

2 participants