From 72961c5858759c6b2f17a32ec63aad0cb4bbeaeb Mon Sep 17 00:00:00 2001 From: shaw Date: Wed, 4 Mar 2026 09:36:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Anthropic=20=E5=B9=B3=E5=8F=B0=E6=97=A0?= =?UTF-8?q?=E9=99=90=E6=B5=81=E9=87=8D=E7=BD=AE=E6=97=B6=E9=97=B4=E7=9A=84?= =?UTF-8?q?=20429=20=E4=B8=8D=E5=86=8D=E8=AF=AF=E6=A0=87=E8=AE=B0=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E9=99=90=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/service/ratelimit_service.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/internal/service/ratelimit_service.go b/backend/internal/service/ratelimit_service.go index 84bf95ce..96e30db2 100644 --- a/backend/internal/service/ratelimit_service.go +++ b/backend/internal/service/ratelimit_service.go @@ -676,7 +676,17 @@ func (s *RateLimitService) handle429(ctx context.Context, account *Account, head } } - // 没有重置时间,使用默认5分钟 + // Anthropic 平台:没有限流重置时间的 429 可能是非真实限流(如 Extra usage required), + // 不标记账号限流状态,直接透传错误给客户端 + if account.Platform == PlatformAnthropic { + slog.Warn("rate_limit_429_no_reset_time_skipped", + "account_id", account.ID, + "platform", account.Platform, + "reason", "no rate limit reset time in headers, likely not a real rate limit") + return + } + + // 其他平台:没有重置时间,使用默认5分钟 resetAt := time.Now().Add(5 * time.Minute) slog.Warn("rate_limit_no_reset_time", "account_id", account.ID, "platform", account.Platform, "using_default", "5m") if err := s.accountRepo.SetRateLimited(ctx, account.ID, resetAt); err != nil {