summaryrefslogtreecommitdiff
path: root/internal/executor/ratelimit.go
blob: ee9a33685cd5daefb71b9edc2e0653bf6c84990a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package executor

import "strings"

// isQuotaExhausted returns true if err indicates the 5-hour Claude usage quota
// is fully exhausted. Unlike transient rate limits, these should not be retried.
func isQuotaExhausted(err error) bool {
	if err == nil {
		return false
	}
	msg := strings.ToLower(err.Error())
	return strings.Contains(msg, "hit your limit") ||
		strings.Contains(msg, "you've hit your limit") ||
		strings.Contains(msg, "you have hit your limit") ||
		strings.Contains(msg, "rate limit reached (rejected)") ||
		strings.Contains(msg, "status: rejected") ||
		// Gemini CLI quota exhaustion
		strings.Contains(msg, "terminalquotaerror") ||
		strings.Contains(msg, "exhausted your daily quota") ||
		strings.Contains(msg, "generate_content_free_tier_requests")
}