fix(failover): 将 HTTP 529 (overloaded_error) 纳入降级触发条件#125
Merged
Conversation
Anthropic API 过载时返回 529,但该状态码未被纳入 FailoverConfig.status_codes, 导致请求被原样透传给客户端而未触发向下级 vendor 的降级。 - FailoverConfig 默认 status_codes 添加 529 - config.default.yaml 配置模板同步添加 529 - BaseVendor.should_trigger_failover 备用安全网逻辑添加 529 - 新增 3 个 529 降级相关单元测试 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
问题背景
Anthropic API 在服务过载时返回 HTTP 529 (
overloaded_error),但 coding-proxy 的故障转移触发条件 (FailoverConfig.status_codes) 仅包含[429, 403, 503, 500],导致 529 被原样透传给客户端,反复重试均失败而未触发向下级 vendor 的降级。现象:
claude-sonnet-4-6请求持续收到 529 Overloaded,即使下级 vendor(zhipu、copilot 等)可用也不会自动降级,客户端只能被动等待。根因分析
BaseVendor.should_trigger_failover()的第一道检查status_code not in self._failover_config.status_codes直接拦截了 529 → 返回False。备用安全网return status_code in (429, 503)同样不包含 529。变更内容
config/resiliency.pyFailoverConfig.status_codes默认值添加529config/config.default.yaml529vendors/base.py(429, 503)→(429, 503, 529)tests/test_vendors.py此修复对所有 vendor 通用生效(非仅限 Anthropic),任何 vendor 返回 529 均会触发向下级的降级。
测试验证
🤖 Generated with Claude Code, CodeX, Gemini