diff options
Diffstat (limited to 'internal/retry/backoff.go')
| -rw-r--r-- | internal/retry/backoff.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/retry/backoff.go b/internal/retry/backoff.go index a372b37..72b923c 100644 --- a/internal/retry/backoff.go +++ b/internal/retry/backoff.go @@ -22,7 +22,13 @@ const maxBackoffDelay = 5 * time.Minute // OpenAI-compatible error text (internal/llm); "rate_limit_error", // "overloaded_error", and "529" additionally match Anthropic's Messages API // error shape (HTTP 429 with error.type "rate_limit_error", or HTTP 529 -// with error.type "overloaded_error" — see internal/provider/anthropic). +// with error.type "overloaded_error" — see internal/provider/anthropic); +// "resource_exhausted" additionally matches Gemini's generateContent API +// error shape (HTTP 429 with error.status "RESOURCE_EXHAUSTED" — see +// internal/provider/google). The plain "429" check above already covers +// Gemini's HTTP status code, but the status string is matched too for +// parity with how the Anthropic error types are matched by name, not just +// by status code. func IsRateLimitError(err error) bool { if err == nil { return false @@ -34,7 +40,8 @@ func IsRateLimitError(err error) bool { strings.Contains(msg, "overloaded") || strings.Contains(msg, "rate_limit_error") || strings.Contains(msg, "overloaded_error") || - strings.Contains(msg, "529") + strings.Contains(msg, "529") || + strings.Contains(msg, "resource_exhausted") } // ParseRetryAfter extracts a Retry-After duration from an error message. |
