fix(ratelimit): 修复 OpenAI usage_limit_reached 错误的重置时间解析 #386
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
问题描述
OpenAI 的
usage_limit_reached错误(实际需要 37 小时重置)被错误地设置为 5 分钟,导致账户在 5 分钟后又被标记为可调度,但实际仍然被限流。症状:
根本原因
handle429方法只检查 Anthropic 的响应头anthropic-ratelimit-unified-reset,没有解析 OpenAI 响应体中的resets_in_seconds字段。OpenAI 的
usage_limit_reached错误格式:{ "error": { "message": "The usage limit has been reached", "type": "usage_limit_reached", "resets_at": 1769404154, "resets_in_seconds": 133107 } }解决方案
parseOpenAIRateLimitResetTime函数解析 OpenAI 响应体handle429中优先尝试解析 OpenAI 格式,然后是 Gemini 格式,最后才使用默认 5 分钟影响