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 @@ -1221,7 +1221,21 @@ export class Cline extends EventEmitter<ClineEvents> {
12211221 }
12221222
12231223 const baseDelay = requestDelaySeconds || 5
1224- const exponentialDelay = Math . ceil ( baseDelay * Math . pow ( 2 , retryAttempt ) )
1224+ let exponentialDelay = Math . ceil ( baseDelay * Math . pow ( 2 , retryAttempt ) )
1225+
1226+ // If the error is a 429, and the error details contain a retry delay, use that delay instead of exponential backoff
1227+ if ( error . status === 429 ) {
1228+ const geminiRetryDetails = error . errorDetails ?. find (
1229+ ( detail : any ) => detail [ "@type" ] === "type.googleapis.com/google.rpc.RetryInfo" ,
1230+ )
1231+ if ( geminiRetryDetails ) {
1232+ const match = geminiRetryDetails ?. retryDelay ?. match ( / ^ ( \d + ) s $ / )
1233+ if ( match ) {
1234+ exponentialDelay = Number ( match [ 1 ] ) + 1
1235+ }
1236+ }
1237+ }
1238+
12251239 // Wait for the greater of the exponential delay or the rate limit delay
12261240 const finalDelay = Math . max ( exponentialDelay , rateLimitDelay )
12271241
You can’t perform that action at this time.
0 commit comments