mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 01:47:47 +08:00
Merge pull request #789 from zhefox/codex/fix-antigravity-quota
Codex/fix antigravity quota
This commit is contained in:
@@ -2042,6 +2042,15 @@ fn pool_score_hard_state_for_status(
|
||||
return Some(pool_score_hard_state_for_terminal_error_reason(&reason));
|
||||
}
|
||||
|
||||
// A number of providers report account quota exhaustion as HTTP 429 rather
|
||||
// than 402. Keep those members out of the score-based pool fallback until
|
||||
// the provider's quota probe observes a reset; treating every 429 as a
|
||||
// generic cooldown otherwise lets the member re-enter as soon as the short
|
||||
// transient cooldown expires.
|
||||
if status_code == 429 && error_body_indicates_quota_exhaustion(error_body) {
|
||||
return Some(PoolMemberHardState::QuotaExhausted);
|
||||
}
|
||||
|
||||
match status_code {
|
||||
401 | 403 => Some(PoolMemberHardState::AuthInvalid),
|
||||
402 => Some(PoolMemberHardState::QuotaExhausted),
|
||||
@@ -2064,6 +2073,27 @@ fn pool_score_hard_state_for_status(
|
||||
}
|
||||
}
|
||||
|
||||
fn error_body_indicates_quota_exhaustion(error_body: Option<&str>) -> bool {
|
||||
let body = error_body.unwrap_or_default().to_ascii_lowercase();
|
||||
[
|
||||
"quota exhausted",
|
||||
"quota_exhausted",
|
||||
"quota exceeded",
|
||||
"quota_exceeded",
|
||||
"insufficient_quota",
|
||||
"resource exhausted",
|
||||
"resource has been exhausted",
|
||||
"resource_exhausted",
|
||||
"usage_limit_reached",
|
||||
"limit_reached",
|
||||
"quota limit reached",
|
||||
"credits exhausted",
|
||||
"insufficient credits",
|
||||
]
|
||||
.iter()
|
||||
.any(|marker| body.contains(marker))
|
||||
}
|
||||
|
||||
fn pool_score_hard_state_for_terminal_error_reason(reason: &str) -> PoolMemberHardState {
|
||||
if reason.starts_with("payment_required_") {
|
||||
PoolMemberHardState::QuotaExhausted
|
||||
@@ -3635,6 +3665,13 @@ mod tests {
|
||||
),
|
||||
Some(PoolMemberHardState::QuotaExhausted)
|
||||
);
|
||||
assert_eq!(
|
||||
pool_score_hard_state_for_status(
|
||||
429,
|
||||
Some(r#"{"error":{"status":"RESOURCE_EXHAUSTED","message":"quota exhausted"}}"#),
|
||||
),
|
||||
Some(PoolMemberHardState::QuotaExhausted)
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user