• shaw's avatar
    fix: Anthropic 429 限流使用精确的窗口重置时间而非聚合最大值 · e6814314
    shaw authored
    当账号仅触发 5h 窗口限流时,旧逻辑从聚合头
    anthropic-ratelimit-unified-reset 读取重置时间,该值为所有窗口的
    最大值(即 7d 重置时间),导致账号被标记为不可调度约 6 天。
    
    新增 calculateAnthropic429ResetTime 函数,解析 Anthropic 的
    per-window 头(5h-utilization/reset、7d-utilization/reset、
    surpassed-threshold),判断实际触发的窗口并使用对应的重置时间:
    - 仅 5h 超标 → 使用 5h-reset(约 5 小时)
    - 仅 7d 超标 → 使用 7d-reset
    - 两者均超标 → 使用 7d-reset(较长冷却)
    - per-window 头不存在 → 回退到聚合头(向后兼容)
    e6814314
ratelimit_service_anthropic_test.go 6.64 KB