yg6888 on X (tweet 2123308968848379920): in a group routed Smart, Cursor Plus's Composer and Grok 4.7 were never used. Not a bug: Smart orders by allowance tier, then soonest renewal, then listed order, and never weighs the context window, so the 1M members listed ahead always answered. The small ones were only ever reached as a fallback. Smart itself is unchanged; changing its order would move every Smart user's traffic. A group gets a new routing instead, `fit` (Small context first; 小上下文优先, 小上下文優先, 小さいコンテキスト優先, Kleiner Kontext zuerst): - routes.SmallFirst takes Smart's order and sorts it stably by band (a provider set to be used first, the rest with room, the all but used up) and then by window, the smaller known first, an unknown one last. - Its strategy sets ByWindow, so weighRouted fills Seat.Window from windowIn (the provider's own Contexts, else the catalog's). - roomy already leaves out every member the request is estimated past, so the first left is the smallest that holds it: a small model is never asked for a request too long for it, and keeps its last-resort place as under every routing. - The trace's rows carry `context`; the Routing page says "its 200K context window is the smallest that holds this request". - A group's only: provider.normalize already drops it from a provider and the CLI refuses it there. GUI menu, hint, why-lines, TUI and CLI (`routing=fit`, small-first) carry it; docs/reference.md, the gateway-routing and plugin-runtime pages and the en/zh/ja start pages say it, with the search index rebuilt (via docs-index.mjs; #7065). Run first at the tree rebased on origin/main6e5882109, then at this head's (on 856423806; search index rebuilt; gateway/routes vet, routes, rotation, ./internal/gui, the gateway's new tests and routing-small-first, routing-group-strategy and i18n-keys 42/42 again), mote over its cores with another session's full suite on it and mica's disk full, so on the Linux box (wsl-run) and the Windows box: - go test -tags nogui ./internal/routes ./internal/cli ./internal/tui ./plugins/rotation ./internal/gateway -count=1 -timeout 45m: all ok but gateway, whose one red was this commit's own new test asserting a single group while an auto group for the shared model exists; fixed (FindGroup "group/g") and the window/strategy tests rerun ok, both new ones pass. ./internal/provider ok (its only FAIL was the stale search index, since rebuilt). ./internal/gui -run Budget ok. - Broken by hand: SmallFirst returning Smart's order makes TestSmallFirstOrdersByWindow and the gateway test red ("a short request went to big first"); dropping fit from SaveGroup's whitelist makes the gateway test red ("the group didn't keep Small context first"). - GUI (Chromium + WebKit, en zh zh-TW ja de): routing-small-first, routing-group-strategy, i18n-keys, routing-cheapest-first, routing-free-expiring 112/112 before and after the rebase; every routing*, group* and builtins* file (253): 4139 of 4198, the 59 reds in 11 files that fail the same at origin/main239da9991run alone (57; routing-many-keys moves between languages each run), all filed: #7016, #7097, #6520, #5049, #6512, #4711, #3954, #3799, #4082. - Windows: CGO_ENABLED=0 go vet -tags nogui ./internal/... ./plugins/... ok. gofmt -l clean. Not tried: the full `go test ./...` and darwin vet (mote busy, mica out of disk); a real Cursor/Grok account in a group (the window comes from the same windowIn roomy already trusts). Seen on the way: a recovered "close of closed channel" in continuation_test.go's doneHold fake, no test failed from it.
38 lines
1.4 KiB
Go
38 lines
1.4 KiB
Go
package routes
|
|
|
|
import (
|
|
"slices"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// Small context first (yg6888 on X) puts the seat whose model's context
|
|
// window is smallest first, so a request that fits it leaves the big ones
|
|
// for those only they hold (the gateway has left out every seat the
|
|
// request is longer than, roomy). A window not known goes after every
|
|
// known one; seats of one window go as Smart orders them (the sooner
|
|
// renewal first); one all but used up still goes after those with room,
|
|
// whatever its window.
|
|
func TestSmallFirstOrdersByWindow(t *testing.T) {
|
|
soon, later := time.Now().Add(2*time.Hour), time.Now().Add(72*time.Hour)
|
|
seats := []Seat{
|
|
{Key: "1m", Known: true, Window: 1_000_000},
|
|
{Key: "unknown", Known: true},
|
|
{Key: "256k-later", Known: true, Window: 256_000, Soon: []time.Time{later}},
|
|
{Key: "200k-spent", Known: true, Window: 100_000, Used: 100},
|
|
{Key: "256k-soon", Known: true, Window: 256_000, Soon: []time.Time{soon}},
|
|
{Key: "200k", Known: true, Window: 200_000},
|
|
}
|
|
var got []string
|
|
for _, i := range Apply(SmallFirst, "g", seats) {
|
|
got = append(got, seats[i].Key)
|
|
}
|
|
want := []string{"200k", "256k-soon", "256k-later", "1m", "unknown", "200k-spent"}
|
|
if !slices.Equal(got, want) {
|
|
t.Fatalf("Small context first ordered %v, want %v", got, want)
|
|
}
|
|
if !SmallFirst.ByWindow || Builtin["fit"].Order == nil {
|
|
t.Fatal("Small context first doesn't weigh windows or isn't registered as fit")
|
|
}
|
|
}
|