File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1230,7 +1230,21 @@ export class Cline extends EventEmitter<ClineEvents> {
12301230 }
12311231
12321232 const baseDelay = requestDelaySeconds || 5
1233- const exponentialDelay = Math . ceil ( baseDelay * Math . pow ( 2 , retryAttempt ) )
1233+ let exponentialDelay = Math . ceil ( baseDelay * Math . pow ( 2 , retryAttempt ) )
1234+
1235+ // If the error is a 429, and the error details contain a retry delay, use that delay instead of exponential backoff
1236+ if ( error . status === 429 ) {
1237+ const geminiRetryDetails = error . errorDetails ?. find (
1238+ ( detail : any ) => detail [ "@type" ] === "type.googleapis.com/google.rpc.RetryInfo" ,
1239+ )
1240+ if ( geminiRetryDetails ) {
1241+ const match = geminiRetryDetails ?. retryDelay ?. match ( / ^ ( \d + ) s $ / )
1242+ if ( match ) {
1243+ exponentialDelay = Number ( match [ 1 ] ) + 1
1244+ }
1245+ }
1246+ }
1247+
12341248 // Wait for the greater of the exponential delay or the rate limit delay
12351249 const finalDelay = Math . max ( exponentialDelay , rateLimitDelay )
12361250
You can’t perform that action at this time.
0 commit comments