File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -403,6 +403,26 @@ func TestFailedModelCheckKeepsTransientFailuresDegraded(t *testing.T) {
403403 }
404404}
405405
406+ func TestLoadModelChecksNormalizesPaidFreeModelErrors (t * testing.T ) {
407+ s := newTestServer (t )
408+ checks := map [string ]modelCheckStatus {
409+ modelCheckKey ("openrouter" , "minimax/minimax-m2.5:free" ): {
410+ Status : "free_degraded" ,
411+ Error : "api error (HTTP 404): This model is unavailable for free. The paid version is available now." ,
412+ },
413+ }
414+ data , err := json .Marshal (checks )
415+ if err != nil {
416+ t .Fatal (err )
417+ }
418+ s .settings = & fakeSettingsStore {values : map [string ]string {settingKeyModelChecks : string (data )}}
419+
420+ got := s .modelCheckStatus (context .Background (), "openrouter" , "minimax/minimax-m2.5:free" )
421+ if got .Status != "free_blocked" {
422+ t .Fatalf ("status = %s, want free_blocked" , got .Status )
423+ }
424+ }
425+
406426func TestFreeModelCheckCandidatesSkipFreshChecks (t * testing.T ) {
407427 s , _ := newTGModelTestServer (t )
408428 fresh := time .Now ().Add (- time .Hour ).Format (time .RFC3339 )
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ func (s *Server) loadModelChecks(ctx context.Context) map[string]modelCheckStatu
8989 s .logger .Warn ("model checks cache parse failed" , "err" , err )
9090 return nil
9191 }
92+ normalizeModelChecks (out )
9293 return out
9394}
9495
@@ -218,6 +219,15 @@ func isBlockedModelCheckError(message string) bool {
218219 return false
219220}
220221
222+ func normalizeModelChecks (checks map [string ]modelCheckStatus ) {
223+ for key , check := range checks {
224+ if check .Status == "free_degraded" && isBlockedModelCheckError (check .Error ) {
225+ check .Status = "free_blocked"
226+ checks [key ] = check
227+ }
228+ }
229+ }
230+
221231func (s * Server ) startModelCheckScheduler () {
222232 if s .settings == nil || s .capStore == nil || s .cfgRef == nil {
223233 return
You can’t perform that action at this time.
0 commit comments