-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Allow disabling API retries by setting maxApiRetries to 0 #387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This reverts commit 32c5488.
Modified the maxApiRetries slider in settings to accept 0 as minimum value, allowing users to completely disable automatic API retry attempts. Updated the aria-label to clarify that 0 means no limit will be applied.
|
|
#355 (comment) Let's just say things happened and I broke the other PR. |
| // note that this api_req_failed ask is unique in that we only present this option if the api hasn't streamed any content yet (ie it fails on the first chunk due), as it would allow them to hit a retry button. However if the api failed mid-stream, it could be in any arbitrary state where some tools may have executed, so that error is handled differently and requires cancelling the task entirely. | ||
| if (alwaysApproveResubmit) { | ||
| const { maxApiRetries } = await this.providerRef.deref()?.getState() ?? {} | ||
| const currentRetryCount = (this.apiRetryCount || 0) + 1 | ||
| this.apiRetryCount = currentRetryCount | ||
|
|
||
| if (maxApiRetries !== undefined && maxApiRetries !== 0 && currentRetryCount > maxApiRetries) { | ||
| const errorMsg = `Maximum retry attempts (${maxApiRetries}) reached. ${error.message ?? "Unknown error"}` | ||
| await this.say("error", errorMsg) | ||
| throw error | ||
| } | ||
|
|
||
| const errorMsg = error.message ?? "Unknown error" | ||
| const requestDelay = requestDelaySeconds || 5 | ||
| // Automatically retry with delay | ||
| // Show countdown timer in error color | ||
| for (let i = requestDelay; i > 0; i--) { | ||
| await this.say("api_req_retry_delayed", `${errorMsg}\n\nRetrying in ${i} seconds...`, undefined, true) | ||
| await this.say("api_req_retry_delayed", `${errorMsg}\n\nRetrying in ${i} seconds...${maxApiRetries !== undefined && maxApiRetries > 0 ? ` (Attempt ${currentRetryCount} of ${maxApiRetries})` : ''}`, undefined, true) | ||
| await delay(1000) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the part I'd be the most careful about when reviewing. If it's wrong/it should be done a different way, I'd love to know!
|
Heads up that I ran prettier on the whole codebase in #404, and it will run automatically in a pre-commit hook going forward. In order to bring this PR up to date on formatting you'll need to run |
Description
Type of change
How Has This Been Tested?
Checklist:
Additional context
Related Issues
Reviewers
Important
Adds
maxApiRetriessetting to disable API retries inCline, with UI and state management updates.maxApiRetriessetting inClineto allow disabling API retries by setting it to 0.Clineto respectmaxApiRetriessetting.maxApiRetriestoExtensionStateinExtensionStateContext.tsx.ClineProviderto handlemaxApiRetriesin state and webview messages.maxApiRetriesslider toSettingsView.tsxfor user configuration.SettingsView.test.tsxto test newmaxApiRetriesfunctionality.maxApiRetriesbehavior inCline.test.tsandClineProvider.test.ts.This description was created by
for e7599ea. It will automatically update as commits are pushed.