diff --git a/backend/internal/service/openai_capacity_shed_model_rule_test.go b/backend/internal/service/openai_capacity_shed_model_rule_test.go index 5f8c64bb70..8e5848633e 100644 --- a/backend/internal/service/openai_capacity_shed_model_rule_test.go +++ b/backend/internal/service/openai_capacity_shed_model_rule_test.go @@ -202,3 +202,16 @@ func TestOpenAICapacityShedModelRule_ErrorFieldsOnly(t *testing.T) { }) } } + +func TestOpenAICapacityShedModelRule_OtherPlatformKeepsDefault(t *testing.T) { + repo := &modelNotFoundAccountRepoStub{} + svc := &OpenAIGatewayService{rateLimitService: &RateLimitService{accountRepo: repo}} + account := openAICapacityShedModelRuleAccount(AccountTypeOAuth) + account.Platform = PlatformGrok + payload := []byte(`{"type":"error","error":{"code":"server_is_overloaded","message":"overloaded"}}`) + failover := svc.newOpenAIStreamFailoverErrorWithModel(nil, account, false, "", payload, "overloaded", "grok-4") + require.Empty(t, repo.modelRateLimitCalls) + require.Zero(t, repo.tempCalls) + require.True(t, failover.RetryableOnSameAccount) + require.True(t, failover.RequestScopedTransient) +} diff --git a/backend/internal/service/openai_gateway_passthrough.go b/backend/internal/service/openai_gateway_passthrough.go index 568bb35731..f42e4b0f75 100644 --- a/backend/internal/service/openai_gateway_passthrough.go +++ b/backend/internal/service/openai_gateway_passthrough.go @@ -1644,6 +1644,9 @@ func (s *OpenAIGatewayService) handleOpenAIStreamTerminalAccountSideEffects( canonicalModel ...string, ) (int, bool) { statusCode := openAIStreamFailureStatus(payload, message) + if statusCode == http.StatusServiceUnavailable && (account == nil || account.Platform != PlatformOpenAI) { + return statusCode, false + } switch statusCode { case http.StatusForbidden: if !openAIStream403AccountFailure(payload, message) { diff --git a/backend/internal/service/openai_gateway_upstream_errors.go b/backend/internal/service/openai_gateway_upstream_errors.go index 565ac058a1..db13c916e0 100644 --- a/backend/internal/service/openai_gateway_upstream_errors.go +++ b/backend/internal/service/openai_gateway_upstream_errors.go @@ -455,7 +455,7 @@ func (s *OpenAIGatewayService) newOpenAIAccountFailoverErrorWithClassificationHe upstreamMsg, retryableOnSameAccount || oauth429Retry, ) - if shouldDisable && failoverErr.RequestScopedTransient { + if shouldDisable && account != nil && account.Platform == PlatformOpenAI && failoverErr.RequestScopedTransient { // A configured model cooldown takes precedence over capacity-shed replay. failoverErr.RetryableOnSameAccount = false }