diff --git a/sdk/cliproxy/auth/manager.go b/sdk/cliproxy/auth/manager.go index 4a6491ce..45602773 100644 --- a/sdk/cliproxy/auth/manager.go +++ b/sdk/cliproxy/auth/manager.go @@ -523,14 +523,14 @@ func (m *Manager) MarkResult(ctx context.Context, result Result) { switch statusCode { case 401: auth.StatusMessage = "unauthorized" - auth.NextRefreshAfter = now.Add(30 * time.Minute) + auth.NextRetryAfter = now.Add(30 * time.Minute) if result.Model != "" { shouldSuspendModel = true suspendReason = "unauthorized" } case 402, 403: auth.StatusMessage = "payment_required" - auth.NextRefreshAfter = now.Add(30 * time.Minute) + auth.NextRetryAfter = now.Add(30 * time.Minute) if result.Model != "" { shouldSuspendModel = true suspendReason = "payment_required" @@ -540,14 +540,14 @@ func (m *Manager) MarkResult(ctx context.Context, result Result) { auth.Quota.Exceeded = true auth.Quota.Reason = "quota" auth.Quota.NextRecoverAt = now.Add(30 * time.Minute) - auth.NextRefreshAfter = auth.Quota.NextRecoverAt + auth.NextRetryAfter = auth.Quota.NextRecoverAt if result.Model != "" { shouldSuspendModel = true registry.GetGlobalRegistry().SetModelQuotaExceeded(auth.ID, result.Model) } case 408, 500, 502, 503, 504: auth.StatusMessage = "transient upstream error" - auth.NextRefreshAfter = now.Add(1 * time.Minute) + auth.NextRetryAfter = now.Add(1 * time.Minute) if result.Model != "" { shouldSuspendModel = false suspendReason = "forbidden" diff --git a/sdk/cliproxy/auth/selector.go b/sdk/cliproxy/auth/selector.go index 7a52af1d..62136b7f 100644 --- a/sdk/cliproxy/auth/selector.go +++ b/sdk/cliproxy/auth/selector.go @@ -28,7 +28,7 @@ func (s *RoundRobinSelector) Pick(ctx context.Context, provider, model string, o now := time.Now() for i := range auths { candidate := auths[i] - if candidate.Unavailable && candidate.Quota.NextRecoverAt.After(now) { + if candidate.Unavailable && candidate.NextRetryAfter.After(now) { continue } if candidate.Status == StatusDisabled || candidate.Disabled { diff --git a/sdk/cliproxy/auth/types.go b/sdk/cliproxy/auth/types.go index 216eb448..27b5314d 100644 --- a/sdk/cliproxy/auth/types.go +++ b/sdk/cliproxy/auth/types.go @@ -43,6 +43,8 @@ type Auth struct { LastRefreshedAt time.Time `json:"last_refreshed_at"` // NextRefreshAfter is the earliest time a refresh should retrigger. NextRefreshAfter time.Time `json:"next_refresh_after"` + // NextRetryAfter is the earliest time a retry should retrigger. + NextRetryAfter time.Time `json:"next_retry_after"` // Runtime carries non-serialisable data used during execution (in-memory only). Runtime any `json:"-"`