mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-28 08:08:32 +00:00
fix(grok): 保持模型级免费额度隔离
This commit is contained in:
@@ -93,9 +93,9 @@ func TestApplyGrokUpstreamFailure_ModelSpecificFreeUsage(t *testing.T) {
|
||||
|
||||
svc.handleGrokAccountUpstreamError(context.Background(), account, 400, nil, body)
|
||||
|
||||
require.Equal(t, 1, repo.tempUnschedCalls)
|
||||
require.Equal(t, "grok free usage exhausted", repo.lastTempUnschedReason)
|
||||
require.Zero(t, repo.tempUnschedCalls, "model-scoped free usage must not cool sibling models")
|
||||
require.True(t, isGrokModelQuotaBlocked(account.ID, "grok-4.5", time.Now()))
|
||||
require.False(t, isGrokModelQuotaBlocked(account.ID, "grok-4.3", time.Now()))
|
||||
}
|
||||
|
||||
func TestApplyGrokUpstreamFailure_SpendingLimitMarksReauth(t *testing.T) {
|
||||
|
||||
@@ -480,11 +480,10 @@ func (s *OpenAIGatewayService) applyGrokUpstreamFailureDecision(
|
||||
if decision.Model != "" && isGrokModelSpecificFreeUsage(low, decision.Model) {
|
||||
until := time.Now().Add(decision.Cooldown)
|
||||
markGrokModelQuotaBlock(account.ID, decision.Model, until)
|
||||
// Account-wide cool is still applied as a safety net when the body
|
||||
// does not isolate a model cleanly; for model-specific free we only
|
||||
// model-block and skip the long account cool when BlockModel was set
|
||||
// by the classifier... actually free-usage keeps BlockModel false.
|
||||
// Prefer model block + shorter account cool via tempUnschedule below.
|
||||
// The upstream explicitly scoped exhaustion to this model, so an
|
||||
// account-wide cool would incorrectly take healthy sibling models out
|
||||
// of rotation.
|
||||
return true
|
||||
}
|
||||
coolUntil := time.Now().Add(decision.Cooldown)
|
||||
markGrokFreeUsageRecovery(account.ID, coolUntil)
|
||||
|
||||
Reference in New Issue
Block a user