mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Parse the retry out of the gemini 429 response (#2118)
This commit is contained in:
parent
a7d31aa9ba
commit
2c5f956162
1 changed files with 15 additions and 1 deletions
|
|
@ -1230,7 +1230,21 @@ export class Cline extends EventEmitter<ClineEvents> {
|
|||
}
|
||||
|
||||
const baseDelay = requestDelaySeconds || 5
|
||||
const exponentialDelay = Math.ceil(baseDelay * Math.pow(2, retryAttempt))
|
||||
let exponentialDelay = Math.ceil(baseDelay * Math.pow(2, retryAttempt))
|
||||
|
||||
// If the error is a 429, and the error details contain a retry delay, use that delay instead of exponential backoff
|
||||
if (error.status === 429) {
|
||||
const geminiRetryDetails = error.errorDetails?.find(
|
||||
(detail: any) => detail["@type"] === "type.googleapis.com/google.rpc.RetryInfo",
|
||||
)
|
||||
if (geminiRetryDetails) {
|
||||
const match = geminiRetryDetails?.retryDelay?.match(/^(\d+)s$/)
|
||||
if (match) {
|
||||
exponentialDelay = Number(match[1]) + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the greater of the exponential delay or the rate limit delay
|
||||
const finalDelay = Math.max(exponentialDelay, rateLimitDelay)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue