mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-06 08:06:19 +00:00
fix(openai): restrict capacity cooldown to explicit overload
Count only confirmed capacity rejections toward account cooldown, excluding generic server failures and unrecognized upstream errors. Classify streamed invalid_prompt failures as invalid requests, matching official Codex. Cover HTTP and WebSocket failures around the cooldown threshold while preserving retry boundaries, upstream error payloads, and Smart scoring. Update the capacity cooldown contract in the API and architecture docs. Validation: Rustfmt, strict workspace Clippy, and all backend suites with isolated PostgreSQL 18 / Redis 8 (--test-threads=4). Reference: openai/codex@7498521d28, codex-rs/codex-api/src/sse/responses.rs. Refs #177 Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
+3
-2
@@ -1153,8 +1153,9 @@ User-Agent 使用 `grok-shell/<版本> (<系统>; <架构>)`,其中 `arm64`
|
||||
|
||||
### 账号自动冻结
|
||||
|
||||
账号自动冻结(`accountAutoFreezeEnabled`)默认关闭。启用后,在统计窗口内按尝试累计容量类上游错误(`server_is_overloaded`
|
||||
等与 5xx 不可用),达到阈值后把该账号冻结为带恢复倒计时的 `rate_limited` 状态。`accountAutoFreezeThreshold`
|
||||
账号自动冻结(`accountAutoFreezeEnabled`)默认关闭。启用后,在统计窗口内按尝试累计明确的上游容量拒绝
|
||||
(`server_is_overloaded`、`slow_down` 或结构化错误中的明确过载提示),普通 5xx、`invalid_prompt` 和未识别的上游错误不计入。
|
||||
达到阈值后把该账号冻结为带恢复倒计时的 `rate_limited` 状态。`accountAutoFreezeThreshold`
|
||||
取值 2~1,000(默认 12,按普通请求的 attempt 计数,含请求内同账号重试,不含诊断探测与本地连接保护错误);`accountAutoFreezeWindowSeconds`
|
||||
取值 60~3,600(默认 600,随每次失败滑动顺延);`accountAutoFreezeDurationSeconds` 取值 300~604,800
|
||||
(默认 7,200,即 2 小时,探测失败后按该时长顺延)。`accountAutoFreezeProbeEnabled` 开启时恢复 worker
|
||||
|
||||
@@ -555,9 +555,10 @@ Worker 由各 Bundle 贡献、由 Host 统一监督:
|
||||
以及账号冻结恢复 worker(容量熔断的自适应并发下调与到期探测解冻);
|
||||
- Provider:credential refresh、quota/catalog 健康和官方版本/etag 检查。
|
||||
|
||||
账号容量熔断默认关闭。启用后,仅普通请求收到的容量类上游错误(`server_is_overloaded` 等与
|
||||
5xx 不可用)按滑动窗口计数,并把当时观测到的在途并发并入峰值证据;本地连接保护与诊断探测
|
||||
不参与容量计数或峰值采样。这些错误不证明凭据或配额失效,不进入账号失败状态。达到阈值后写入
|
||||
账号容量熔断默认关闭。启用后,仅普通请求收到的明确容量拒绝(`server_is_overloaded`、`slow_down`
|
||||
或结构化错误中的明确过载提示)按滑动窗口计数,并把当时观测到的在途并发并入峰值证据;
|
||||
普通 5xx、未识别的上游错误、本地连接保护与诊断探测不参与容量计数或峰值采样。
|
||||
这些错误不证明凭据或配额失效,不进入账号失败状态。达到阈值后写入
|
||||
账号级 Redis 容量冷却,调度立即跳过该账号;管理端沿用限流状态,通过原因区分容量冻结与上游限流。
|
||||
冻结与计数由 Redis 保存,不改变 PostgreSQL 账号状态。需要探测的冻结在到期后仍阻止调度,恢复
|
||||
worker 复用连接测试探针执行真实上游调用,并按冻结代次处理结果:成功清除,失败按配置时长顺延,
|
||||
|
||||
Reference in New Issue
Block a user