mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-12-05 08:00:53 +00:00
fix(openai): limit model retry hints to scoped rate limits
Keep ordinary account cooldowns on their existing selection path, including peer accounts after quota synchronization. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
1 parent
2ddcd7c936
commit
7d6e4cc4e7
1 file changed
+9
-7
@@ -694,14 +694,14 @@ impl CodexCredentialSelector {
|
||||
.then(|| (id.clone(), state))
|
||||
})
|
||||
.collect();
|
||||
let mut unsupported = BTreeSet::new();
|
||||
let mut model_rate_limited_accounts = BTreeSet::new();
|
||||
for (account, cooldown) in native.zip(model_cooldowns) {
|
||||
if let Some(cooldown) = cooldown.ok().flatten().filter(|cooldown| {
|
||||
cooldown.credential_revision() == account.revision()
|
||||
&& cooldown.until() > SystemTime::now()
|
||||
}) {
|
||||
if cooldown.rate_limited_until() != Some(cooldown.until()) {
|
||||
unsupported.insert(account.id().clone());
|
||||
if cooldown.rate_limited_until() == Some(cooldown.until()) {
|
||||
model_rate_limited_accounts.insert(account.id().clone());
|
||||
}
|
||||
// 两种冷却取较晚期限,保留账号级冷却的恢复探测语义
|
||||
active
|
||||
@@ -713,7 +713,7 @@ impl CodexCredentialSelector {
|
||||
});
|
||||
}
|
||||
}
|
||||
(active, unsupported)
|
||||
(active, model_rate_limited_accounts)
|
||||
}
|
||||
|
||||
async fn select_inner_loop(
|
||||
@@ -1098,7 +1098,7 @@ impl CodexCredentialSelector {
|
||||
continue 'capacity;
|
||||
}
|
||||
let follow_only = follow_only && image_primary_to_keep.is_none();
|
||||
let (rate_limits, unsupported_models) = if diagnostic {
|
||||
let (rate_limits, model_rate_limited_accounts) = if diagnostic {
|
||||
Default::default()
|
||||
} else {
|
||||
self.load_candidate_cooldowns(&accounts, &account_ids, &native_accounts, model)
|
||||
@@ -1473,10 +1473,12 @@ impl CodexCredentialSelector {
|
||||
}
|
||||
// 只判断本次账号范围;空池、认证失效和租约失败不能伪装成额度耗尽
|
||||
// 策略排除与临时容量阻塞分开,保留繁忙账号的可恢复语义
|
||||
// 冷却在选号前就会排除账号;等待期限也须服从本轮插件裁决后的范围
|
||||
// 只有本轮可选账号的原生模型限流才提供等待提示
|
||||
let cooldown_retry = candidates
|
||||
.iter()
|
||||
.filter(|candidate| !unsupported_models.contains(candidate.account.id()))
|
||||
.filter(|candidate| {
|
||||
model_rate_limited_accounts.contains(candidate.account.id())
|
||||
})
|
||||
.filter(|candidate| {
|
||||
!context.excluded_accounts.contains(candidate.account.id())
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user