What changed: the gateway keeps, per classifier model, why it couldn't
say the last time it was asked (an error from the request, or an answer
that was no number of the list) and when, until it answers again
(gateway.ClassifierFailure). The first failure, and each one that says
something new, is written to the log once ("routing: the classifier X
couldn't say: ..."). /api/groups sends it as a group's classifierFailed,
and the group's card on Routing shows a line "Classifier failed 3 min
ago: <why>" with an amber dot (no stripe); its title says that until the
classifier answers, no rule with an intent matches and turns reason as
the agent asked. Strings in en, zh, zh-TW, ja and de.
Why: versun's MLX-Serve answered its Clef decision model, asked as a
chat model, with a 400. The only place that said so was each request's
own details; the group's rules with an intent quietly never matched,
which read as the routing working. The preset itself is fixed in the
commit before this one (versun's, cherry-picked).
Run:
- go test: TestClassifierFailureIsKept (gateway: a 400, kept while
resting, "not a number", cleared by an answer) and
TestGroupsSayAClassifierThatFailed (gui: only the failing group's JSON
has classifierFailed). Each went red with its line removed by hand
(the record in classify(), the fill in groupsState).
- group-classifier-failed.test.cjs: chromium and webkit, en zh zh-TW ja
de, at 1100 and 420: 20/20; with classifierFailed dropped from the
fixture's reading in groupRow, 10/10 of one engine red. i18n-keys
passes.
- go test -tags nogui ./internal/provider ./internal/usage ./internal/cli:
ok. ./internal/gateway hit the 10m default timeout at load ~150-190
(other sessions); rerun with a longer timeout before the push, below.
- go test ./internal/gui: TestDockJoinLeadsCommandTab (Command-Tab order
had kitty in front) and TestMainWindowCorners (measuring killed under
load) failed; both are desktop-window tests this change doesn't touch.
Not verified: a real MLX-Serve; versun ran his own.
51 lines
1.9 KiB
Go
51 lines
1.9 KiB
Go
package gateway
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// A classifier that can't say at every turn is said where the group is,
|
|
// not only in each request's own details (#1929, versun): MLX-Serve turned
|
|
// its decision model away as a chat model with a 400, and the group's
|
|
// rules with an intent quietly never matched. ClassifierFailure is why it
|
|
// couldn't say the last time it was asked, an answer that was no answer
|
|
// among them, until it answers.
|
|
func TestClassifierFailureIsKept(t *testing.T) {
|
|
resetClassified(t)
|
|
s, _, _, c := intented(t, provider.Rule{Use: "b/big", Intent: "refactoring"})
|
|
if _, _, ok := ClassifierFailure("c/cls"); ok {
|
|
t.Fatal("a failure before it was asked")
|
|
}
|
|
c.set("", 400)
|
|
t0 := time.Now()
|
|
_, r := postOK(t, s, "cf1", chat("rename this package", nil, 0, ""))
|
|
why, at, ok := ClassifierFailure("c/cls")
|
|
if !ok || !strings.Contains(why, "classifier down") || at.Before(t0) || r.Rule.Classified.Error == "" {
|
|
t.Fatalf("400: %q %v %v (%+v)", why, at, ok, r.Rule.Classified)
|
|
}
|
|
// resting, it isn't asked; what it last said stays
|
|
_, r = postOK(t, s, "cf2", chat("rename that package", nil, 0, ""))
|
|
if why2, _, ok := ClassifierFailure("c/cls"); !ok || why2 != why || !strings.Contains(r.Rule.Classified.Error, "not asked again") {
|
|
t.Fatalf("resting: %q %v", why2, ok)
|
|
}
|
|
// an answer that is no number of the list is a failure too
|
|
classified.Lock()
|
|
delete(classified.failed, "c/cls")
|
|
classified.Unlock()
|
|
c.set("maybe", 0)
|
|
postOK(t, s, "cf3", chat("rename it back", nil, 0, ""))
|
|
if why, _, ok := ClassifierFailure("c/cls"); !ok || !strings.Contains(why, "not a number") {
|
|
t.Fatalf("no number: %q %v", why, ok)
|
|
}
|
|
// it answers: nothing to say
|
|
c.set("1", 0)
|
|
_, r = postOK(t, s, "cf4", chat("rename everything", nil, 0, ""))
|
|
if why, _, ok := ClassifierFailure("c/cls"); ok || r.Rule.N != 1 {
|
|
t.Fatalf("answered: %q %+v", why, r.Rule)
|
|
}
|
|
}
|