Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

providers: Best in family serves the newest model of each family a provider lists

yetonee887139e7a0b
diff --git a/docs/subsystems/providers-accounts.md b/docs/subsystems/providers-accounts.md
index 5f5d45c8f..f4b7e1ec8 100644
--- a/docs/subsystems/providers-accounts.md
+++ b/docs/subsystems/providers-accounts.md
@@ -29,7 +29,7 @@ keys and accounts per request is in [Gateway routing and fallback](gateway-routi
| providers.json | `Path` is `providers.json` in magpie's config folder. A read that fails returns `ErrUnreadable` and is never treated as empty. `store` writes atomically through a rename and drops the cached catalog (`catalog.Touched`). | [`provider.go`](../../internal/provider/provider.go) |
| A provider renamed | `Rename` (the editor's id field, `magpie provider set <id> id=<new>`) keeps the old id in `Was`, so a model still picked by it reaches the provider. Usage is recorded under the id a call went out by and never rewritten; whatever reads it names the provider by its id now through `UsageRenames().Of(id, time)`: the summary, the Requests page (its blocks, the probe rows, other computers' days), the Sessions tab's vias, window holds, `NewPricer`/`NewCoster` and the gateway's `loggedAnswers` (cybercaius on Discord: a renamed provider was listed under both ids). `Visit` hands records out as recorded, so `Of` is taken once. An id another provider takes later (a rename onto it, or `Save` of a new provider under it) moves from the first one's `Was` to its `Gave` with the time (`giveID`): calls recorded under it before then stay the first one's, later ones are the new one's. An id held by a provider or a subscription now is never renamed (`Renamed`), and `freeID` doesn't hand out an id in any `Was`, so adding a vendor again gets `-2`. Ids reused before `Gave` existed have no time and go to whoever holds the id now. A provider deleted (`Delete`) is kept in providers.json's `deleted` with its name, `Was`, `Gave` and when (`provider.Deleted`): its calls stay under its id while no provider has that id, and once one is added under it (or a later deleted one had it) they go to `Deleted.UsageID`, `<id>~<when, UTC>`, so the new provider has only its own (cybercaius on Discord). The Usage page names either by the deleted provider's name and marks it with when it was deleted (`Renames.Gone`, `Named.Deleted`). Deletes before this was kept have no record and go to whoever holds the id now. A deleted provider's calls can be merged into a provider there is now, or named by the user, from a "…" beside the Requests page's Provider filter while it is picked (`ledProviderMore` in `plugins/usage/page.js`, `POST /api/usage/deleted`, `GET /api/usage/deleted/into`; CyberCaius on Discord, who had renamed a provider onto the old id to do it). Both are kept on its `Deleted` record, not in settings and never in the log: `MergeDeleted` sets `Into` and `MergedAt`, `NameDeleted` sets `Label` (`Deleted.Shown`), so a provider added later under the old id inherits neither. `Renames.Both(id, time)` gives the id a call is shown under (`Of`, merges followed) and the one it was made to (`Own`): a merged call is listed, filtered and summed under the target, but priced, held and answered by its own (`Record.priceID`, `block_price.go`'s `as`, window holds, `loggedAnswers`), so a merge moves no cost or token. The target's face lists what is merged into it (`Named.Merged`), and the same "…" parts each again (`into` ""). Renaming the target carries the merge; deleting it ends it (a merge older than the target's deletion is not followed). A providers.json that can't be read keeps the last renames read, not none. The summary and Requests caches key on `Renames.Key`, the vias cache too. | [`rename.go`](../../internal/provider/rename.go), [`block_price.go`](../../internal/usage/block_price.go) |
| The list | `All` merges stored providers with `Accounts()`. An entry with no URL stores the user's picks for an account. The order is `file.Order`. Reads within one request share one build (`Hold`, #746). | [`provider.go`](../../internal/provider/provider.go) |
-| Model picks | `Models` are the models the user picked for agents; none means the vendor's list, up to 24 (`Exposed`), unless the user chose Select none (`NoModels`, `magpie provider models <id> none`): then none of its models is served, not to agents, not to any routing group (auto groups included), not by a `provider/model` id, not as a classifier, while its balance and usage are still read (`ServesNone`, #1818). Codex's own list at `/backend-api/codex/models` drops the ChatGPT account's visible models too, as spawn_agent's list of them does, and the list's ETag changes so a running Codex asks again (`CodexNativePicked` in [`codex_models.go`](../../internal/provider/codex_models.go), #2530); the hidden ones Codex runs jobs of its own on (codex-auto-review, gpt-reserve) and other providers' models stay. The editor's serves control names it Usage only, beside Vendor's list and Picked only, and the card says "usage only" (#2068); Picked only from there picks the models the vendor's list serves, to unpick from. A file without `noModels` reads as before, and a pick clears it. `Save` keeps beside new picks the models listed then (`PickedFrom`, `listedWith`), and the same picks saved again keep it. When the picks held every model listed then, one the vendor lists since is served first beside them (`withNewlyListed`, `Picks`); one listed then and left unpicked stays out. Picks saved before `PickedFrom` was kept are taken to hold every model when they hold every one released up to the newest of them (models.dev's `release_date`), so a Claude account whose user picked them all is served Haiku 5.5 (wakaka). The editor and the TUI start from `Picks`, so a later Save keeps the new model. While some picks are set aside (the list is known to be short), a save with new picks keeps the models the earlier `PickedFrom` had beside those listed now, so a model the user saw and left unpicked isn't new when that list has it again; a list short of no pick is taken as it is. A pick a list fetched again stops listing (`Refetch`, `KeepListsFresh`, and a plugin's hourly `KeepPluginsListed`) leaves `Models` for `Delisted` (`dropGonePicks`), not served, and goes back among the picks when a later list has it (`relistPicks`): Our Free Model's plugin lists its account channels' models only once its service has read them after a restart, and its free pools only while they answer, so each magpie update had its user pick every model again (多喝热水 on Discord). Every save keeps `Delisted` but for what it picks again (`delistedWith`); Select none clears it. A provider whose every pick is in `Delisted` serves none of its models (`waitsForPicks`), not the vendor's list. `KeepPluginsListed` asks again after `relistSoon` (5 minutes) when a list left a pick out. `TestPluginPicksComeBackWithTheirList`, `TestEveryPickDelistedServesNone` and `TestRelayPicksComeBackWithTheirList` cover it. | [`models.go`](../../internal/provider/models.go), [`provider.go`](../../internal/provider/provider.go) |
+| Model picks | `Models` are the models the user picked for agents; none means the vendor's list, up to 24 (`Exposed`), unless the user chose Select none (`NoModels`, `magpie provider models <id> none`): then none of its models is served, not to agents, not to any routing group (auto groups included), not by a `provider/model` id, not as a classifier, while its balance and usage are still read (`ServesNone`, #1818). Codex's own list at `/backend-api/codex/models` drops the ChatGPT account's visible models too, as spawn_agent's list of them does, and the list's ETag changes so a running Codex asks again (`CodexNativePicked` in [`codex_models.go`](../../internal/provider/codex_models.go), #2530); the hidden ones Codex runs jobs of its own on (codex-auto-review, gpt-reserve) and other providers' models stay. The editor's serves control names it Usage only, beside Vendor's list and Picked only, and the card says "usage only" (#2068); Picked only from there picks the models the vendor's list serves, to unpick from. A file without `noModels` reads as before, and a pick clears it. With nothing picked and Select none off, Best in family (`BestInFamily`, `magpie provider models <id> best`, the editor's fourth option, Steven on Discord) serves only the newest model of each family the vendor lists, up to 24: the family is the id with its version numbers taken out, a dated snapshot counts as its alias, and sizes and suffixes (-mini, -pro, -8b) stay in the name (`FamilyOf`, `BestInFamily` in [`family.go`](../../internal/catalog/family.go)). A newer one the vendor lists later takes the old one's place with nothing saved. Codex's own list narrows the same way (`CodexNativePicked`). An older one named by its `provider/model` id is still served, as an unpicked one is under Picked only. A pick or Select none clears it, and a file without `bestInFamily` reads as before. `Save` keeps beside new picks the models listed then (`PickedFrom`, `listedWith`), and the same picks saved again keep it. When the picks held every model listed then, one the vendor lists since is served first beside them (`withNewlyListed`, `Picks`); one listed then and left unpicked stays out. Picks saved before `PickedFrom` was kept are taken to hold every model when they hold every one released up to the newest of them (models.dev's `release_date`), so a Claude account whose user picked them all is served Haiku 5.5 (wakaka). The editor and the TUI start from `Picks`, so a later Save keeps the new model. While some picks are set aside (the list is known to be short), a save with new picks keeps the models the earlier `PickedFrom` had beside those listed now, so a model the user saw and left unpicked isn't new when that list has it again; a list short of no pick is taken as it is. A pick a list fetched again stops listing (`Refetch`, `KeepListsFresh`, and a plugin's hourly `KeepPluginsListed`) leaves `Models` for `Delisted` (`dropGonePicks`), not served, and goes back among the picks when a later list has it (`relistPicks`): Our Free Model's plugin lists its account channels' models only once its service has read them after a restart, and its free pools only while they answer, so each magpie update had its user pick every model again (多喝热水 on Discord). Every save keeps `Delisted` but for what it picks again (`delistedWith`); Select none clears it. A provider whose every pick is in `Delisted` serves none of its models (`waitsForPicks`), not the vendor's list. `KeepPluginsListed` asks again after `relistSoon` (5 minutes) when a list left a pick out. `TestPluginPicksComeBackWithTheirList`, `TestEveryPickDelistedServesNone` and `TestRelayPicksComeBackWithTheirList` cover it. | [`models.go`](../../internal/provider/models.go), [`provider.go`](../../internal/provider/provider.go) |
| List schedule and rules | A provider of the user's own (not an account, a plugin's or a decision-only one) can set `RefreshEvery` (`magpie provider refresh-every <id> 6h`, or 1d, or off, at least 10m) and `AutoInclude` (`magpie provider auto-include <id> 'gpt-*' 're:claude-.*'`, or none; a glob with `*`, or `re:` matching the whole id, both in any case (`compilePattern`; `(?-i)` inside a `re:` makes case matter); a plain id is refused) (#2135). The gateway (`magpie serve` or the app) looks each minute and fetches a list once `Fetched` is that old, through the same `Refetch` as Fetch models (`KeepListsFresh`); a failed fetch waits `min(every, 15m)`. `RefetchTaking` adds to the picks a model the fetch newly lists that a rule matches (`takeMatching`), starting from what is served now (`Exposed`), so nothing served is taken away and a model the user unticks stays out (it is not new to the next fetch). Setting the rules takes the current list's matches. Every save that doesn't set them keeps them, the window's editor among them; the editor has no fields for them yet. A Remote magpie with no `RefreshEvery` is fetched every 10m (`RemoteMagpieEvery`, `RefreshSchedule`), so a model the other magpie lists later (ZCode's GLM-5.3-Trial once its plugin read the gift, 6igsteven on Discord) is served without Fetch models; `off` set on it is kept as `"off"` and asks it only when told (`TestRemoteMagpieListFollowsTheOtherMagpie`). | [`autolist.go`](../../internal/provider/autolist.go), [`models.go`](../../internal/provider/models.go), [`providers_cli.go`](../../internal/cli/providers_cli.go) |
| Keys | Several keys per provider. Requests go to the first key that is on; the gateway moves on when it is out or rate limited. `Key` stays the first, so other code reads it as before. A key can be made for one protocol (`KeyProtocol`). A key made for a protocol its provider has no URL for is skipped (`perKeyBarred`); when every key is, the provider is still tried whole on the URLs it has, and the candidate carries `noURL` so it isn't quiet: Routing's row (`Weighed.NoURL`) says "key set to {api} only, no {api} URL · sent on the others", and the editor's key row shows a "No {api} URL" chip (`keyLacksURL`; #1702, `TestKeyForAProtocolWithNoURLIsSaid`, `key-nourl.test.cjs`). A key's value can be replaced in place (`ReplaceKey`, #1869: a key rotated at the vendor): it keeps its name, place, protocol, weight and on or off, and what was set for it by its fingerprint (`AccountModels`, `AccountProxies`, `AccountConcurrency`) and the gateway keys held to it (`access.ReplaceAccount`) move to the new one; the GUI's `keys/replace` also lifts its rests (`UnrestAll`). Its past requests stay under the old fingerprint, by the same name. A provider may hold thousands of keys (@NetRozee on X: a thousand froze magpie). Nothing goes over its keys once for each key: `KeysOn` drops a repeat by a set, a row's rest keys come from `RestKeys` (whether several are on, found once), and whether each key serves a model from `Serving`, which reads the lists once and keeps each model's keys as a set until the lists are read anew (`keyLists`). `KeysListed` and `ListsRead` count them for the tests (`TestProviderInfoListsKeysOnce`, `TestPerKeyReadsListsOnce`). A provider's keys have their balances, plans and remote limits read `keyReadsAtOnce` (8) at a time (`keySlots`); other providers' beside them. The editor's per-key proxy lines fold as its Accounts list does (`proxyLines`, `provider-many-keys-proxy.test.cjs`). Asking a key's models (`fetchPerKey`) still goes one key after another. | [`keys.go`](../../internal/provider/keys.go) |
| A provider with no key | A provider of the user's own saves, imports and is `Ready` with no key when it is a preset with `NoKey` or its host is on this computer or the user's own network (`keyOptional`, `ownNetwork`): localhost, a loopback, private, link-local or carrier-grade NAT (Tailscale's 100.64/10) address, or a `.local` name, read from the URL alone with no lookup. A company's keyless relay at a LAN address is taken as a local server is (iSnow_999 on X: a Codex relay at http://<LAN IP>:8080 was left out of a CC Switch import as "it has no API key"); a keyless address on the internet still needs its key. With no key it is asked as one on 127.0.0.1 is: a Responses request carries no `Authorization`. | [`provider.go`](../../internal/provider/provider.go), [`importapps.go`](../../internal/provider/importapps.go), [`import_lan_test.go`](../../internal/provider/import_lan_test.go) |
diff --git a/internal/catalog/family.go b/internal/catalog/family.go
new file mode 100644
index 000000000..2d7998d3e
--- /dev/null
+++ b/internal/catalog/family.go
@@ -0,0 +1,177 @@
+package catalog
+
+import (
+ "regexp"
+ "slices"
+ "strconv"
+ "strings"
+)
+
+// A model's family is its id with the version numbers taken out, so that
+// claude-opus-4-8 and claude-opus-5-5 are claude-opus, o3 and o1 are o, and
+// o4-mini is o-mini. Nothing about a vendor is compiled in: what is read
+// off the id alone is
+//
+// - a version: a number (4, 4.5, the 4 and 5 of claude-opus-4-5), the
+// digits a word ends in (qwen3, o4, k2), a v and its digits (v3,
+// v1:0), or the digits a word starts with that aren't a size (gpt-4o
+// is gpt-o, glm-4.5v glm-v);
+// - a size, which stays in the name: 8b, 70b, 1.5b, a22b, 8x7b, 128e,
+// 32k, so qwen3-32b and qwen3-8b are two families;
+// - a snapshot: a date or revision after the version (20251101, 0528,
+// 2507, 2024-08-06, 05-20, 001), read as the alias it was taken of;
+// - a preview (preview, exp, beta): the same model before its release,
+// so gemini-3-pro-preview is a gemini-pro;
+// - latest, an alias of the newest, which is the alias too.
+//
+// Every other word stays in the name: -mini, -pro, -nano, -flash,
+// -flash-lite, -codex, -thinking, -instruct, :free, and a provider prefix
+// (anthropic/, us.anthropic.).
+
+// Family is what an id's name says about it: the family it belongs to and
+// where it stands in it.
+type Family struct {
+ Name string // the id without its version, snapshot or preview
+ Version []int // every version number, in the order the id has them
+ Snapshot string // its dates or revision, "" for an alias
+ Preview bool
+}
+
+var (
+ familySep = regexp.MustCompile(`[-_/:@\[\]\s]+`)
+ // a number: 4, 4.5, 2.0
+ familyNum = regexp.MustCompile(`^\d+(?:\.\d+)*$`)
+ // a word that ends in its version: qwen3, qwen2.5, o4, k2, v1, llama3.1
+ familyTail = regexp.MustCompile(`^([a-z][a-z.]*?[a-z])(\d+(?:\.\d+)*)$|^([a-z])(\d+(?:\.\d+)*)$`)
+ // a word that starts with its version: 4o, 4.5v, 3n
+ familyHead = regexp.MustCompile(`^(\d+(?:\.\d+)*)([a-z]+)$`)
+ // a size, kept in the name: 8b, 1.5b, 70b, 128e, 32k, 8x7b, a22b, e4b
+ familySize = regexp.MustCompile(`^(?:[a-z]?\d+(?:\.\d+)?|\d+x\d+(?:\.\d+)?)[bmkte]$`)
+ familyYear = regexp.MustCompile(`^(?:19|20)\d\d$`)
+)
+
+var familyPreview = map[string]bool{"preview": true, "exp": true, "experimental": true, "beta": true, "alpha": true}
+
+// FamilyOf reads id's family off its name.
+func FamilyOf(id string) Family {
+ s := strings.ToLower(strings.TrimSpace(id))
+ words := familySep.Split(s, -1)
+ seps := familySep.FindAllString(s, -1)
+ // which purely numeric words are a snapshot rather than a version
+ snap := make([]bool, len(words))
+ for i, w := range words {
+ if !familyNum.MatchString(w) || strings.Contains(w, ".") {
+ continue
+ }
+ // a date or revision: 0528, 2507, 20251101, 2024, 001, 05
+ if len(w) >= 4 || len(w) >= 2 && w[0] == '0' {
+ snap[i] = true
+ }
+ }
+ for i, w := range words {
+ if snap[i] || !familyNum.MatchString(w) || len(w) != 2 {
+ continue
+ }
+ // the day after a month (05-20), the month before a year (12-2024)
+ if i > 0 && snap[i-1] || i+1 < len(words) && familyYear.MatchString(words[i+1]) {
+ snap[i] = true
+ }
+ }
+ var f Family
+ var name, snaps strings.Builder
+ keep := func(i int, w string) {
+ if name.Len() > 0 && i > 0 {
+ name.WriteString(seps[i-1])
+ }
+ name.WriteString(w)
+ }
+ addVersion := func(v string) {
+ for _, n := range strings.Split(v, ".") {
+ x, err := strconv.Atoi(n)
+ if err != nil {
+ x = 0
+ }
+ f.Version = append(f.Version, x)
+ }
+ }
+ for i, w := range words {
+ switch {
+ case w == "":
+ case snap[i]:
+ if snaps.Len() > 0 {
+ snaps.WriteString("-")
+ }
+ snaps.WriteString(w)
+ case familyPreview[w]:
+ f.Preview = true
+ case w == "latest":
+ case familyNum.MatchString(w):
+ addVersion(w)
+ case familySize.MatchString(w):
+ keep(i, w)
+ default:
+ if m := familyTail.FindStringSubmatch(w); m != nil {
+ word, v := m[1], m[2]
+ if word == "" {
+ word, v = m[3], m[4]
+ }
+ if word != "v" { // v3, v1: the version alone
+ keep(i, word)
+ }
+ addVersion(v)
+ } else if m := familyHead.FindStringSubmatch(w); m != nil {
+ addVersion(m[1])
+ keep(i, m[2])
+ } else {
+ keep(i, w)
+ }
+ }
+ }
+ f.Name, f.Snapshot = name.String(), snaps.String()
+ if f.Name == "" {
+ f.Name = s // all numbers: a family of its own
+ }
+ return f
+}
+
+// newerInFamily says a, of the same family as b, is the one to serve over
+// it: the higher version; at the same version a release over a preview,
+// then the alias over a dated snapshot (the alias names the vendor's
+// current one), then the later release date, then the later snapshot.
+func newerInFamily(a, b Model, fa, fb Family) bool {
+ if c := slices.Compare(fa.Version, fb.Version); c != 0 {
+ return c > 0
+ }
+ if fa.Preview != fb.Preview {
+ return fb.Preview
+ }
+ if (fa.Snapshot == "") != (fb.Snapshot == "") {
+ return fa.Snapshot == ""
+ }
+ if a.Released != b.Released {
+ return a.Released > b.Released
+ }
+ return fa.Snapshot > fb.Snapshot
+}
+
+// BestInFamily is ms with only the newest model of each family left
+// (FamilyOf, newerInFamily), in the order ms has them. A family's first
+// listed wins a tie.
+func BestInFamily(ms []Model) []Model {
+ fams := make([]Family, len(ms))
+ best := map[string]int{}
+ for i, m := range ms {
+ fams[i] = FamilyOf(m.ID)
+ j, ok := best[fams[i].Name]
+ if !ok || newerInFamily(m, ms[j], fams[i], fams[j]) {
+ best[fams[i].Name] = i
+ }
+ }
+ out := make([]Model, 0, len(best))
+ for i, m := range ms {
+ if best[fams[i].Name] == i {
+ out = append(out, m)
+ }
+ }
+ return out
+}
diff --git a/internal/catalog/family_test.go b/internal/catalog/family_test.go
new file mode 100644
index 000000000..b54838340
--- /dev/null
+++ b/internal/catalog/family_test.go
@@ -0,0 +1,169 @@
+package catalog
+
+import (
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "slices"
+ "sort"
+ "testing"
+)
+
+// The ids here are real: models.dev's (the local catalog of 10-29), Codex's
+// own list and Bedrock's.
+func TestFamilyOf(t *testing.T) {
+ for _, c := range []struct {
+ id, name string
+ version []int
+ snapshot string
+ preview bool
+ }{
+ {"claude-opus-4-8", "claude-opus", []int{4, 8}, "", false},
+ {"claude-opus-5-5", "claude-opus", []int{5, 5}, "", false},
+ {"claude-opus-5", "claude-opus", []int{5}, "", false},
+ // a dated snapshot is its alias
+ {"claude-opus-4-5-20251101", "claude-opus", []int{4, 5}, "20251101", false},
+ {"claude-haiku-4-5-20251001", "claude-haiku", []int{4, 5}, "20251001", false},
+ {"gpt-4o-2024-08-06", "gpt-o", []int{4}, "2024-08-06", false},
+ {"deepseek-r1-0528", "deepseek-r", []int{1}, "0528", false},
+ {"qwen3-235b-a22b-instruct-2507", "qwen-235b-a22b-instruct", []int{3}, "2507", false},
+ {"gemini-2.5-flash-preview-05-20", "gemini-flash", []int{2, 5}, "05-20", true},
+ {"gemini-embedding-001", "gemini-embedding", nil, "001", false},
+ {"command-r7b-12-2024", "command-r7b", nil, "12-2024", false},
+ // the version mid-name
+ {"claude-3-5-sonnet-20241022", "claude-sonnet", []int{3, 5}, "20241022", false},
+ {"meta-llama/llama-3.3-70b-instruct", "meta-llama/llama-70b-instruct", []int{3, 3}, "", false},
+ // sizes and suffixes stay in the name
+ {"gpt-5.4-mini", "gpt-mini", []int{5, 4}, "", false},
+ {"gpt-5.5-pro", "gpt-pro", []int{5, 5}, "", false},
+ {"gpt-4.1-nano", "gpt-nano", []int{4, 1}, "", false},
+ {"gpt-5.3-codex-spark", "gpt-codex-spark", []int{5, 3}, "", false},
+ {"qwen3.6-27b", "qwen-27b", []int{3, 6}, "", false},
+ {"qwen3.6-35b-a3b", "qwen-35b-a3b", []int{3, 6}, "", false},
+ {"mistralai/mixtral-8x7b-instruct", "mistralai/mixtral-8x7b-instruct", nil, "", false},
+ {"gemma-3n-e4b-it", "gemma-n-e4b-it", []int{3}, "", false},
+ // gemini: flash, flash-lite and pro are three
+ {"gemini-3.5-flash", "gemini-flash", []int{3, 5}, "", false},
+ {"gemini-3.5-flash-lite", "gemini-flash-lite", []int{3, 5}, "", false},
+ {"gemini-3.1-pro-preview", "gemini-pro", []int{3, 1}, "", true},
+ {"gemini-pro-latest", "gemini-pro", nil, "", false},
+ // the o-series
+ {"o3", "o", []int{3}, "", false},
+ {"o4-mini", "o-mini", []int{4}, "", false},
+ {"o1-pro", "o-pro", []int{1}, "", false},
+ // a word that ends in its version
+ {"kimi-k2.6", "kimi-k", []int{2, 6}, "", false},
+ {"glm-4.6v", "glm-v", []int{4, 6}, "", false},
+ {"deepseek-v4-flash", "deepseek-flash", []int{4}, "", false},
+ // a provider prefix stays
+ {"anthropic/claude-opus-4.5", "anthropic/claude-opus", []int{4, 5}, "", false},
+ {"us.anthropic.claude-sonnet-4-5-20250929-v1:0", "us.anthropic.claude-sonnet", []int{4, 5, 1, 0}, "20250929", false},
+ {"Qwen/Qwen3.8-27B", "qwen/qwen-27b", []int{3, 8}, "", false},
+ {"claude-sonnet-4-5[1m]", "claude-sonnet[1m", []int{4, 5}, "", false},
+ } {
+ f := FamilyOf(c.id)
+ if f.Name != c.name || !slices.Equal(f.Version, c.version) || f.Snapshot != c.snapshot || f.Preview != c.preview {
+ t.Errorf("FamilyOf(%q) = %+v, want {%s %v %q %v}", c.id, f, c.name, c.version, c.snapshot, c.preview)
+ }
+ }
+}
+
+// Different models never share a family.
+func TestFamilyKeepsModelsApart(t *testing.T) {
+ for _, pair := range [][2]string{
+ {"gpt-5.4", "gpt-5.4-mini"},
+ {"gpt-5.4-mini", "gpt-5.4-nano"},
+ {"gpt-5.5", "gpt-5.5-pro"},
+ {"gpt-4", "gpt-4o"},
+ {"o3", "o3-mini"},
+ {"o3", "o3-pro"},
+ {"gemini-3.5-flash", "gemini-3.1-pro-preview"},
+ {"gemini-3.5-flash", "gemini-3.5-flash-lite"},
+ {"qwen3-8b", "qwen3-32b"},
+ {"llama-3.1-8b-instruct", "llama-3.1-70b-instruct"},
+ {"gpt-6.1-sol", "gpt-6.1-terra"},
+ {"claude-opus-5-5", "claude-sonnet-5-5"},
+ {"kimi-k2-thinking", "kimi-k2"},
+ {"openai/gpt-5", "azure/gpt-5"},
+ {"deepseek/deepseek-r1:free", "deepseek/deepseek-r1"},
+ } {
+ if a, b := FamilyOf(pair[0]).Name, FamilyOf(pair[1]).Name; a == b {
+ t.Errorf("%s and %s are both %q", pair[0], pair[1], a)
+ }
+ }
+}
+
+func familyModels(ids ...string) []Model {
+ out := make([]Model, len(ids))
+ for i, id := range ids {
+ out[i] = Model{ID: id}
+ }
+ return out
+}
+
+// Anthropic's list as models.dev had it on 10-27, release dates and all:
+// Haiku 5.5, Sonnet 5.5, Opus 5.5 and Fable 5.1, in the list's order.
+func TestBestInFamilyClaude(t *testing.T) {
+ body, err := os.ReadFile(filepath.Join("testdata", "models.dev-2026-10-27-claude.json"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ var d map[string]struct {
+ Models map[string]struct {
+ Released string `json:"release_date"`
+ } `json:"models"`
+ }
+ if err := json.Unmarshal(body, &d); err != nil {
+ t.Fatal(err)
+ }
+ var ms []Model
+ for id, m := range d["anthropic"].Models {
+ ms = append(ms, Model{ID: id, Released: m.Released})
+ }
+ // newest first, as the vendor's list has them
+ sort.Slice(ms, func(i, j int) bool {
+ return ms[i].Released > ms[j].Released || ms[i].Released == ms[j].Released && ms[i].ID < ms[j].ID
+ })
+ got := ids(BestInFamily(ms))
+ want := slices.DeleteFunc(ids(ms), func(id string) bool {
+ return !slices.Contains([]string{"claude-haiku-5-5", "claude-sonnet-5-5", "claude-opus-5-5", "claude-fable-5-1"}, id)
+ })
+ if !slices.Equal(got, want) || len(got) != 4 {
+ t.Errorf("BestInFamily(anthropic) = %v, want %v", got, want)
+ }
+}
+
+func TestBestInFamily(t *testing.T) {
+ for _, c := range []struct {
+ name string
+ in []Model
+ want []string
+ }{
+ {"codex", familyModels("gpt-6.1-sol", "gpt-6-astra", "gpt-6-sol", "gpt-6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"),
+ []string{"gpt-6.1-sol", "gpt-6-astra", "gpt-6-luna", "gpt-5.6-terra"}},
+ // a newer one listed takes the old one's place by itself
+ {"opus 5.6", familyModels("claude-opus-5-6", "claude-opus-5-5", "claude-sonnet-5-5"), []string{"claude-opus-5-6", "claude-sonnet-5-5"}},
+ {"openai sizes", familyModels("gpt-5.6", "gpt-5.5", "gpt-5.4-mini", "gpt-5-mini", "gpt-4.1-nano", "gpt-5.4-nano", "gpt-5.5-pro", "gpt-5-pro"),
+ []string{"gpt-5.6", "gpt-5.4-mini", "gpt-5.4-nano", "gpt-5.5-pro"}},
+ {"o-series", familyModels("o1", "o3", "o3-mini", "o4-mini", "o1-pro", "o3-pro"), []string{"o3", "o4-mini", "o3-pro"}},
+ {"gemini", familyModels("gemini-2.5-flash", "gemini-3.5-flash", "gemini-2.5-pro", "gemini-3.1-pro-preview", "gemini-3.1-flash-lite-preview", "gemini-3.1-flash-lite", "gemini-pro-latest"),
+ []string{"gemini-3.5-flash", "gemini-3.1-pro-preview", "gemini-3.1-flash-lite"}},
+ // at one version, a release over its preview
+ {"preview", familyModels("gemini-3-pro-image-preview", "gemini-3-pro-image"), []string{"gemini-3-pro-image"}},
+ // the alias over its dated snapshots, whatever their dates say
+ {"snapshots", []Model{{ID: "gpt-4o", Released: "2024-05-13"}, {ID: "gpt-4o-2024-08-06", Released: "2024-08-06"}, {ID: "gpt-4o-2024-11-20", Released: "2024-11-20"}},
+ []string{"gpt-4o"}},
+ {"snapshots alone", []Model{{ID: "mistral-medium-2505", Released: "2025-05-07"}, {ID: "mistral-medium-2508", Released: "2025-08-12"}}, []string{"mistral-medium-2508"}},
+ {"qwen sizes", familyModels("Qwen/Qwen3.5-27B", "Qwen/Qwen3.6-27B", "Qwen/Qwen3.8-27B", "Qwen/Qwen3.6-35B-A3B", "Qwen/Qwen3.5-35B-A3B"),
+ []string{"Qwen/Qwen3.8-27B", "Qwen/Qwen3.6-35B-A3B"}},
+ {"mid-name version", familyModels("claude-3-5-sonnet-20241022", "claude-sonnet-4-5"), []string{"claude-sonnet-4-5"}},
+ {"bedrock", familyModels("us.anthropic.claude-sonnet-4-5-20250929-v1:0", "us.anthropic.claude-sonnet-5-5", "us.meta.llama3-1-70b-instruct-v1:0", "us.meta.llama3-3-70b-instruct-v1:0"),
+ []string{"us.anthropic.claude-sonnet-5-5", "us.meta.llama3-3-70b-instruct-v1:0"}},
+ {"provider prefix", familyModels("openai/gpt-5.5", "openai/gpt-5.6", "azure/gpt-5.5"), []string{"openai/gpt-5.6", "azure/gpt-5.5"}},
+ {"none", nil, nil},
+ } {
+ if got := ids(BestInFamily(c.in)); !slices.Equal(got, c.want) {
+ t.Errorf("%s: BestInFamily = %v, want %v", c.name, got, c.want)
+ }
+ }
+}
diff --git a/internal/cli/provider_models_cli_test.go b/internal/cli/provider_models_cli_test.go
index 45c9da7ff..61c899cbb 100644
--- a/internal/cli/provider_models_cli_test.go
+++ b/internal/cli/provider_models_cli_test.go
@@ -177,3 +177,66 @@ func TestGroupMemberNotExposedSaysHow(t *testing.T) {
}
}
}
+
+// magpie provider models <id> best serves the newest of each family the
+// vendor lists (Best in family, Steven on Discord); all gives the whole
+// list back, and a pick or none clears it.
+func TestProviderModelsBest(t *testing.T) {
+ groupsHome(t)
+ catalog.Changed = nil
+ if err := provider.Save(provider.Provider{ID: "og", Name: "OG", Key: "k", Chat: "http://127.0.0.1:1/v1"}); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.MkdirAll(filepath.Dir(catalog.LivePath("og")), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(catalog.LivePath("og"), []byte(`{"models":[{"id":"gpt-6.1-sol"},{"id":"gpt-6-astra"},{"id":"gpt-6-sol"},{"id":"gpt-6-luna"},{"id":"gpt-5.6-sol"},{"id":"gpt-5.6-terra"},{"id":"gpt-5.6-luna"}]}`), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ catalog.Reset()
+ t.Cleanup(catalog.Reset)
+ run := func(args ...string) (string, error) {
+ return stdoutOf(t, func() error { return providerCmd(append([]string{"provider", "models", "og"}, args...)) })
+ }
+ exposed := func() []string {
+ var out []string
+ for _, m := range mustFind(t, "og").Exposed() {
+ out = append(out, m.ID)
+ }
+ return out
+ }
+ if _, err := run("best"); err != nil {
+ t.Fatal(err)
+ }
+ if p := mustFind(t, "og"); !p.BestInFamily || p.Models != nil || p.NoModels {
+ t.Fatalf("best saved %v noModels %v best %v", p.Models, p.NoModels, p.BestInFamily)
+ }
+ if want := []string{"gpt-6.1-sol", "gpt-6-astra", "gpt-6-luna", "gpt-5.6-terra"}; !slices.Equal(exposed(), want) {
+ t.Fatalf("best exposes %v, want %v", exposed(), want)
+ }
+ // the older ones are named as left out, and why
+ out, err := stdoutOf(t, func() error { return providerCmd([]string{"provider", "og"}) })
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !strings.Contains(out, "gpt-5.6-sol") || !strings.Contains(out, "best in family") {
+ t.Errorf("provider og said %q; want gpt-5.6-sol left out by best in family", out)
+ }
+ if _, err := run("all"); err != nil {
+ t.Fatal(err)
+ }
+ if p := mustFind(t, "og"); p.BestInFamily || len(p.Exposed()) != 7 {
+ t.Fatalf("all after best: best %v exposing %d", p.BestInFamily, len(p.Exposed()))
+ }
+ for _, args := range [][]string{{"gpt-6-sol"}, {"none"}} {
+ if _, err := run("best"); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := run(args...); err != nil {
+ t.Fatal(err)
+ }
+ if p := mustFind(t, "og"); p.BestInFamily {
+ t.Errorf("%v after best kept it", args)
+ }
+ }
+}
diff --git a/internal/cli/providers_cli.go b/internal/cli/providers_cli.go
index 7c2c6910e..2e989c332 100644
--- a/internal/cli/providers_cli.go
+++ b/internal/cli/providers_cli.go
@@ -59,7 +59,8 @@ const providerUsage = `usage:
magpie provider fallback <id> <provider/model>… where requests go when it's out of quota or down (none clears)
magpie provider models <id> [ids…] fetch the vendor's model list, or choose which models to expose:
ids… replace the list, +id adds one, -id takes one out, all: the default,
- none: serve none of them, its balance and usage still shown
+ none: serve none of them, its balance and usage still shown,
+ best: only the newest of each family it lists (Opus 5.6 replaces 5.5 once listed)
magpie provider refresh <id> fetch the vendor's model list again (as the app's Fetch models)
magpie provider refresh-every <id> [6h|1d|off]
have the gateway (magpie serve, the app) fetch the list again by itself
@@ -407,7 +408,9 @@ func notExposed(p provider.Provider) ([]string, string) {
}
}
why := "not picked"
- if len(p.Models) == 0 {
+ if len(p.Models) == 0 && p.BestInFamily {
+ why = "best in family: an older one of its family"
+ } else if len(p.Models) == 0 {
why = fmt.Sprintf("none picked, so only the first %d", len(shown))
}
return out, why
@@ -679,16 +682,19 @@ func providerCmd(args []string) error {
if len(rest) > 1 {
before := *p
// none: no model served at all, the provider kept for its
- // balance and usage (#1818); all is the vendor's list again
+ // balance and usage (#1818); best: the newest of each family
+ // the vendor lists (Best in family); all is the vendor's list
+ // again
none := len(rest) == 2 && rest[1] == "none"
+ best := len(rest) == 2 && rest[1] == "best"
picks, err := editPicks(*p, rest[1:])
- if none {
+ if none || best {
picks, err = nil, nil
}
if err != nil {
return err
}
- p.Models, p.NoModels = picks, none
+ p.Models, p.NoModels, p.BestInFamily = picks, none, best
if err := provider.Save(*p); err != nil {
return err
}
diff --git a/internal/gateway/codex_best_in_family_test.go b/internal/gateway/codex_best_in_family_test.go
new file mode 100644
index 000000000..44196a237
--- /dev/null
+++ b/internal/gateway/codex_best_in_family_test.go
@@ -0,0 +1,99 @@
+package gateway
+
+import (
+ "encoding/json"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "path/filepath"
+ "slices"
+ "testing"
+
+ "github.com/yetone/magpie/internal/provider"
+)
+
+// Best in family on the codex provider keeps Codex's own list to the
+// newest of each family the ChatGPT account lists (Steven on Discord:
+// GPT-6.1-Sol, GPT-6-Astra, GPT-6-Luna, GPT-5.6-Terra), as it does the
+// general catalog: the hidden jobs and other providers' models stay, the
+// ETag changes with it, and spawn_agent names only those.
+func TestCodexBestInFamilyCatalog(t *testing.T) {
+ codexSignedIn(t)
+ const own = `[{"slug":"gpt-6.1-sol","visibility":"list","priority":1},{"slug":"gpt-6-astra","visibility":"list","priority":2},{"slug":"gpt-6-sol","visibility":"list","priority":3},{"slug":"gpt-6-luna","visibility":"list","priority":4},{"slug":"gpt-5.6-sol","visibility":"list","priority":5},{"slug":"gpt-5.6-terra","visibility":"list","priority":6},{"slug":"gpt-5.6-luna","visibility":"list","priority":7},{"slug":"codex-auto-review","visibility":"hide","priority":8}]`
+ os.MkdirAll(filepath.Join(os.Getenv("HOME"), ".codex"), 0o700)
+ os.WriteFile(filepath.Join(os.Getenv("HOME"), ".codex", "models_cache.json"), []byte(`{"etag":"\"v1\"","models":`+own+`}`), 0o600)
+ up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ io.WriteString(w, `{"models":`+own+`}`)
+ }))
+ t.Cleanup(up.Close)
+ was := provider.CodexBase
+ provider.CodexBase = up.URL + "/backend-api/codex"
+ t.Cleanup(func() { provider.CodexBase = was })
+ if err := provider.Save(provider.Provider{ID: "fake", Name: "Fake", Key: "k", Models: []string{"m1"}, Chat: up.URL + "/v1"}); err != nil {
+ t.Fatal(err)
+ }
+ gw := httptest.NewServer(New().Handler())
+ t.Cleanup(gw.Close)
+ all := []string{"gpt-6.1-sol", "gpt-6-astra", "gpt-6-sol", "gpt-6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna"}
+ tags := map[string]string{}
+ for _, tc := range []struct {
+ name string
+ p provider.Provider
+ want []string
+ }{
+ {"vendor list", provider.Provider{ID: "codex"}, all},
+ {"best in family", provider.Provider{ID: "codex", BestInFamily: true}, []string{"gpt-6.1-sol", "gpt-6-astra", "gpt-6-luna", "gpt-5.6-terra"}},
+ {"picked", provider.Provider{ID: "codex", Models: []string{"gpt-6-sol"}, BestInFamily: true}, []string{"gpt-6-sol"}},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ if err := provider.Save(tc.p); err != nil {
+ t.Fatal(err)
+ }
+ req, err := http.NewRequest(http.MethodGet, gw.URL+CodexPath+"/models?client_version=0.163.0", nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+ req.Header.Set("Authorization", "Bearer chatgpt-token")
+ res, err := gw.Client().Do(req)
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer res.Body.Close()
+ if res.StatusCode != http.StatusOK {
+ t.Fatalf("model list status %d", res.StatusCode)
+ }
+ var list struct {
+ Models []struct {
+ Slug string `json:"slug"`
+ } `json:"models"`
+ }
+ if err := json.NewDecoder(res.Body).Decode(&list); err != nil {
+ t.Fatal(err)
+ }
+ var got []string
+ for _, m := range list.Models {
+ got = append(got, m.Slug)
+ }
+ want := append(slices.Clone(tc.want), "codex-auto-review", "fake/m1")
+ slices.Sort(got)
+ slices.Sort(want)
+ if !slices.Equal(got, want) {
+ t.Fatalf("models = %v, want %v", got, want)
+ }
+ tags[tc.name] = res.Header.Get("ETag")
+ var spawn []string
+ for _, c := range spawnChoices(httptest.NewRequest("POST", CodexPath+"/responses", nil), "gpt-6.1-sol", true) {
+ if slices.Contains(all, c.slug) {
+ spawn = append(spawn, c.slug)
+ }
+ }
+ if !slices.Equal(spawn, tc.want) {
+ t.Errorf("spawn_agent offers the account's %v, want %v", spawn, tc.want)
+ }
+ })
+ }
+ if tags["best in family"] == tags["vendor list"] {
+ t.Errorf("ETag kept across Best in family: %q", tags)
+ }
+}
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js
index 40e9e7ea1..d0486fc9d 100644
--- a/internal/gui/assets/app.js
+++ b/internal/gui/assets/app.js
@@ -9194,7 +9194,7 @@ function baseAPIOf(p) {
// draftOf is a saved provider as its editor's form holds it.
function draftOf(p) {
- return { id: p.id, name: p.name, preset: p.preset, chat: p.chat, responses: p.responses, anthropic: p.anthropic, gemini: p.gemini || "", catalog: p.catalog, decide: p.decide || "", key: "", api: baseAPIOf(p), chosen: pickedOf(p), none: !!p.noModels, extra: [], headers: headerRows(p.headers), extraBody: extraBodyText(p.extraBody), replyHeaders: (p.replyHeaders || []).join(", "), icon: p.icon || "", fallback: [...(p.fallback || [])], unlisted: !!p.unlisted, hiddenDrawers: [...(p.hiddenDrawers || [])], searches: !!p.searches, unredacted: !!p.unredacted, insecureTLS: !!p.insecureTLS, limitRestOff: !!p.limitRestOff, nativeCompaction: !!p.nativeCompaction, passUserAgent: !!p.passUserAgent, pinUpstream: !!p.pinUpstream, authHeader: p.authHeader || "", balanceURL: p.balanceURL || "", balancePath: p.balancePath || "", balanceMethod: p.balanceMethod || "", modelsURL: p.modelsURL || "", contexts: contextsText(p.contexts), outputs: contextsText(p.outputs), compacts: contextsText(p.compacts), keysUrl: p.keysUrl || "", ...proxyDraft(p), ...concurrencyDraft(p) };
+ return { id: p.id, name: p.name, preset: p.preset, chat: p.chat, responses: p.responses, anthropic: p.anthropic, gemini: p.gemini || "", catalog: p.catalog, decide: p.decide || "", key: "", api: baseAPIOf(p), chosen: pickedOf(p), none: !!p.noModels, best: !!p.bestInFamily, extra: [], headers: headerRows(p.headers), extraBody: extraBodyText(p.extraBody), replyHeaders: (p.replyHeaders || []).join(", "), icon: p.icon || "", fallback: [...(p.fallback || [])], unlisted: !!p.unlisted, hiddenDrawers: [...(p.hiddenDrawers || [])], searches: !!p.searches, unredacted: !!p.unredacted, insecureTLS: !!p.insecureTLS, limitRestOff: !!p.limitRestOff, nativeCompaction: !!p.nativeCompaction, passUserAgent: !!p.passUserAgent, pinUpstream: !!p.pinUpstream, authHeader: p.authHeader || "", balanceURL: p.balanceURL || "", balancePath: p.balancePath || "", balanceMethod: p.balanceMethod || "", modelsURL: p.modelsURL || "", contexts: contextsText(p.contexts), outputs: contextsText(p.outputs), compacts: contextsText(p.compacts), keysUrl: p.keysUrl || "", ...proxyDraft(p), ...concurrencyDraft(p) };
}
// duplicateProvider opens the Add form on a copy of p (#268): its URLs,
@@ -9541,7 +9541,7 @@ function drawEditor(p, presetID) {
if (priceTypedError(ed)) return;
const picked = accountModelsDraft(p);
if (picked === false) return pickError();
- const body = { id: p.id, models: chosenIds(), noModels: noneChosen(), unlisted: draft.unlisted, hiddenDrawers: draft.hiddenDrawers, fallback: draft.fallback, contexts: cx.map, outputs: ox.map, compacts: cpx.map, proxy, accountProxies: own.map, maxConcurrency, ...queue, priceRate, modelPrefs: modelPrefsOfDraft(), pinUpstream: !!draft.pinUpstream, ...(p.carriesCompaction ? { nativeCompaction: !!draft.nativeCompaction } : {}), ...routingOfDraft(p) };
+ const body = { id: p.id, models: chosenIds(), noModels: noneChosen(), bestInFamily: bestChosen(), unlisted: draft.unlisted, hiddenDrawers: draft.hiddenDrawers, fallback: draft.fallback, contexts: cx.map, outputs: ox.map, compacts: cpx.map, proxy, accountProxies: own.map, maxConcurrency, ...queue, priceRate, modelPrefs: modelPrefsOfDraft(), pinUpstream: !!draft.pinUpstream, ...(p.carriesCompaction ? { nativeCompaction: !!draft.nativeCompaction } : {}), ...routingOfDraft(p) };
saving(saveBtn, t("Saving…"));
saveAccountModelsDraft(picked).then(() => savePluginOptions(subOf(a.agent))).then(() => providerAction("save", body, t("{name} saved", { name: p.name })), (e) => { doneSaving(saveBtn); editorError(e.message || String(e)); }); };
bar.append(cancel, saveBtn);
@@ -10154,7 +10154,7 @@ function drawEditor(p, presetID) {
body.baseAPI = draft.api === "openai" ? "chat" : draft.api;
}
if (custom) { body.icon = draft.icon || "generic"; body.balanceURL = (draft.balanceURL || "").trim(); body.balancePath = (draft.balancePath || "").trim(); body.balanceMethod = draft.balanceMethod || ""; body.modelsURL = (draft.modelsURL || "").trim(); }
- if (p) { body.fallback = draft.fallback; body.unlisted = draft.unlisted; body.hiddenDrawers = draft.hiddenDrawers; body.noModels = noneChosen(); body.modelPrefs = modelPrefsOfDraft(); Object.assign(body, routingOfDraft(p)); }
+ if (p) { body.fallback = draft.fallback; body.unlisted = draft.unlisted; body.hiddenDrawers = draft.hiddenDrawers; body.noModels = noneChosen(); body.bestInFamily = bestChosen(); body.modelPrefs = modelPrefsOfDraft(); Object.assign(body, routingOfDraft(p)); }
body.searches = !!draft.searches && searchable();
body.pinUpstream = !!draft.pinUpstream;
if (twoKeyHeaders()) body.authHeader = draft.authHeader || "";
@@ -11118,10 +11118,12 @@ function chosenIds() {
// provider's models served, not to agents, not to routing groups, while its
// balance and usage still show. Without it no picks is the vendor's list.
const noneChosen = () => !!draft.none && !chosenIds().length;
+// bestChosen: Best in family kept, with nothing picked
+const bestChosen = () => !!draft.best && !draft.none && !chosenIds().length;
// servedIds: the models the provider serves as the editor has it: the
// picks; none after Select none; else those the vendor's list serves
-const servedIds = (p) => draft.chosen.length ? draft.chosen : draft.none ? [] : p.models.filter((m) => m.on).map((m) => m.id);
+const servedIds = (p) => draft.chosen.length ? draft.chosen : draft.none ? [] : p.models.filter((m) => draft.best ? m.best : m.on).map((m) => m.id);
// modelsOpen: a provider editor's models let out to their full height
// (#833), kept for the next editor opened. MCHIPS_MAX: the most the box is
@@ -11175,6 +11177,8 @@ function renderModels(p) {
// agents aren't offered it, so Select all and Free only leave it, and it
// is drawn dimmed, saying why. As saved (m.noAPI), or as the API set for
// it in this editor makes it
+ // dashed: what the vendor's list serves (Best in family: m.best)
+ const dashed = () => p.models.filter((m) => !noAPI(m) && (!draft.best || m.best)).slice(0, 24).map((m) => m.id);
const noAPI = (m) => {
const set = draft.modelPrefs?.[m.id]?.api;
if (set === undefined || !p.speaks?.length) return !!m.noAPI;
@@ -11304,13 +11308,9 @@ function renderModels(p) {
let shown = 0, hidden = 0, unpicked = 0;
// Picked only, unfiltered: the picks alone (unpickedShown)
const picksOnly = draft.chosen.length && !f && unpickedShown !== p.id && !decideOnly(p);
- // with none picked agents are served the vendor's list, up to 24 of
- // it: those are drawn as served, not as left out (#614: the one model
- // unticked and saved was still "1 model" on the card). Kept for routing
- // groups alone, those are what the groups use (#1818: drawn as none
- // while the card and the auto groups had all 17); after Select none,
- // none is served
- const served = draft.chosen.length || decideOnly(p) || draft.none ? new Set() : new Set(p.models.filter((m) => !noAPI(m)).slice(0, 24).map((m) => m.id));
+ // none picked: what the vendor's list serves is drawn as served (#614,
+ // #1818), none after Select none
+ const served = draft.chosen.length || decideOnly(p) || draft.none ? new Set() : new Set(dashed());
// models that would read alike say what tells them apart (modelTells)
const tells = modelTells(p.models);
// a filter is a search: what it doesn't match is left out, picked or not
@@ -11386,6 +11386,7 @@ function renderModels(p) {
drawServes();
why.textContent = decideOnly(p) ? t("Agents never see them: a routing group picks one as its classifier.")
: !draft.chosen.length && draft.none ? t("None selected: no agent or routing group uses its models. Its balance and usage still show. Click a model to pick it.")
+ : bestChosen() && !draft.unlisted ? t("Best in family: agents see the newest model of each family it lists (dashed), up to {n}. A newer one it lists later takes the old one's place.", { n: 24 })
: draft.unlisted ? t(draft.chosen.length ? "Agents don't see them: only the routing groups they are in use them." : "Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.", { n: 24 })
: t(draft.chosen.length ? "Agents see the models picked." : "Vendor's list: agents see up to {n} of its models (dashed), and those it lists later. Click a model to pick just it.", { n: 24 });
drawLost();
@@ -11755,37 +11756,28 @@ function renderModels(p) {
names.style.minHeight = "";
names.scrollTop = top;
};
- // what the provider serves, said in so many words (#1831, kchen0x: with
- // none picked it served every model, with one picked that one, and with
- // that one unpicked every model again, while Select none served none and
- // looked nearly the same): the vendor's list, or the models picked, none
- // when none are. A click on a model, Select all or Select none is
- // "Picked"; only "Vendor's list" goes back to the vendor's list. None
- // picked is Usage only, its own option (#2068, keleus: a subscription
- // kept for its usage alone took Picked only, then Select none, then Save
- // to find): nothing routed to it, its balance and usage still shown.
- // Picked only with none picked starts from what the vendor's list serves
- // (the dashed ones), to unpick from
+ // what the provider serves, in words (#1831): the vendor's list, the
+ // picks (a click on a model, Select all or none), the newest of each
+ // family, or Usage only (#2068). Picked only starts from the dashed ones
const serves = el("div", "segs mserves");
- const servesOpts = [["list", "Vendor's list", "Serve the vendor's list, up to {n} of it (dashed), models it lists later too"], ["picked", "Picked only", "Serve only the models picked"], ["none", "Usage only", "Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show."]].map(([v, name, tip]) => {
+ const servesOpts = [["list", "Vendor's list", "Serve the vendor's list, up to {n} of it (dashed), models it lists later too"], ["picked", "Picked only", "Serve only the models picked"], ["best", "Best in family", "Best in family: agents see the newest model of each family it lists (dashed), up to {n}. A newer one it lists later takes the old one's place."], ["none", "Usage only", "Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show."]].map(([v, name, tip]) => {
const b = el("button", "opt", t(name));
b.dataset.serves = v;
b.title = t(tip, { n: 24 });
b.onclick = () => {
if (v !== "picked" && draft.chosen.length) picksLeft = { id: p.id, picks: [...draft.chosen] };
- if (v === "list") { draft.chosen = []; draft.typed = ""; draft.none = false; }
- else if (v === "none") { draft.chosen = []; draft.typed = ""; draft.none = true; }
+ if (v !== "picked") { draft.chosen = []; draft.typed = ""; draft.none = v === "none"; draft.best = v === "best"; }
else {
if (!draft.chosen.length && picksLeft?.id === p.id) { draft.chosen = picksLeft.picks; draft.none = true; }
- if (!draft.chosen.length) { draft.chosen = p.models.filter((m) => !noAPI(m)).slice(0, 24).map((m) => m.id); draft.none = true; }
- unpickedShown = null;
+ if (!draft.chosen.length) { draft.chosen = dashed(); draft.none = true; }
+ unpickedShown = null; draft.best = false;
}
draw();
};
serves.append(b);
return b;
});
- const servesMode = () => draft.chosen.length ? "picked" : draft.none ? "none" : "list";
+ const servesMode = () => draft.chosen.length ? "picked" : draft.none ? "none" : draft.best ? "best" : "list";
const drawServes = () => {
const now = servesMode();
for (const b of servesOpts) { b.classList.toggle("on", b.dataset.serves === now); b.setAttribute("aria-pressed", b.dataset.serves === now); }
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 2dbbf942e..dd49597e7 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -3661,6 +3661,8 @@ const I18N = {
"Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "提供供应商的列表,最多 {n} 个(虚线框),之后新上的模型也包括在内",
"Serve only the models picked": "只提供勾选的模型",
"Usage only": "仅看用量",
+ "Best in family": "每系最新",
+ "Best in family: agents see the newest model of each family it lists (dashed), up to {n}. A newer one it lists later takes the old one's place.": "每系最新:Agent 看到它列表里每个系列最新的模型(虚线框),最多 {n} 个。之后上了更新的,会自动替换旧的。",
"Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show.": "不往它路由:Agent 和路由分组都不使用它的模型,之后新上的模型也不会加进来。余额和用量照常显示。",
"usage only": "仅看用量",
"Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "供应商列表:Agent 看不到,模型所在的路由分组最多使用其中 {n} 个(虚线框)。点击模型可单选。",
@@ -7763,6 +7765,8 @@ const I18N = {
"Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "提供供應商的列表,最多 {n} 個(虛線框),之後新上的模型也包括在內",
"Serve only the models picked": "只提供勾選的模型",
"Usage only": "僅看用量",
+ "Best in family": "每系最新",
+ "Best in family: agents see the newest model of each family it lists (dashed), up to {n}. A newer one it lists later takes the old one's place.": "每系最新:Agent 看到它列表裡每個系列最新的模型(虛線框),最多 {n} 個。之後上了更新的,會自動取代舊的。",
"Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show.": "不往它路由:Agent 和路由分組都不使用它的模型,之後新上的模型也不會加進來。餘額和用量照常顯示。",
"usage only": "僅看用量",
"Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "供應商列表:Agent 看不到,模型所在的路由分組最多使用其中 {n} 個(虛線框)。點選模型可單選。",
@@ -11886,6 +11890,8 @@ const I18N = {
"Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "ベンダーのリストを最大 {n} 件(破線)提供します。後から追加されたモデルも含みます",
"Serve only the models picked": "選択したモデルだけを提供します",
"Usage only": "使用量のみ",
+ "Best in family": "系列の最新のみ",
+ "Best in family: agents see the newest model of each family it lists (dashed), up to {n}. A newer one it lists later takes the old one's place.": "系列の最新のみ:エージェントには一覧の各系列の最新モデルが見えます(破線、最大 {n} 個)。後で新しいモデルが載ると、古いものと自動で入れ替わります。",
"Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show.": "何もルーティングしません。エージェントもルーティンググループもモデルを使わず、後から追加されたモデルも加わりません。残高と使用量は引き続き表示されます。",
"usage only": "使用量のみ",
"Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "ベンダーのリスト:エージェントには表示されず、モデルが属するルーティンググループが最大 {n} 件(破線)を使います。モデルをクリックするとそれだけを選択します。",
@@ -16022,6 +16028,8 @@ const I18N = {
"Serve the vendor's list, up to {n} of it (dashed), models it lists later too": "Die Liste des Anbieters anbieten, bis zu {n} Modelle (gestrichelt), auch später hinzukommende",
"Serve only the models picked": "Nur die gewählten Modelle anbieten",
"Usage only": "Nur Nutzung",
+ "Best in family": "Neuestes je Familie",
+ "Best in family: agents see the newest model of each family it lists (dashed), up to {n}. A newer one it lists later takes the old one's place.": "Neuestes je Familie: Agents sehen das neueste Modell jeder Familie aus der Liste (gestrichelt), bis zu {n}. Ein neueres, das er später listet, ersetzt das alte.",
"Route nothing to it: no agent or routing group uses its models, and those it lists later aren't added. Its balance and usage still show.": "Nichts dorthin leiten: Weder Agenten noch Weiterleitungsgruppen nutzen seine Modelle, auch später gelistete nicht. Guthaben und Nutzung werden weiter angezeigt.",
"usage only": "nur Nutzung",
"Vendor's list: agents don't see it, the routing groups its models are in use up to {n} of it (dashed). Click a model to pick just it.": "Liste des Anbieters: Agenten sehen sie nicht, die Weiterleitungsgruppen seiner Modelle nutzen bis zu {n} davon (gestrichelt). Klicken Sie auf ein Modell, um nur dieses zu wählen.",
diff --git a/internal/gui/provider_save_best_test.go b/internal/gui/provider_save_best_test.go
new file mode 100644
index 000000000..0e825d5d9
--- /dev/null
+++ b/internal/gui/provider_save_best_test.go
@@ -0,0 +1,109 @@
+package gui
+
+// Best in family (Steven on Discord): the editor's fourth option is saved
+// as bestInFamily with no model picked, kept by a save that doesn't name
+// it, and the card serves the newest of each family; each model says
+// whether it is one (best), so the editor draws them before a save.
+
+import (
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "slices"
+ "strings"
+ "testing"
+
+ "github.com/yetone/magpie/internal/catalog"
+ "github.com/yetone/magpie/internal/provider"
+)
+
+func TestProviderSaveBestInFamily(t *testing.T) {
+ t.Setenv("HOME", t.TempDir())
+ t.Setenv("USERPROFILE", os.Getenv("HOME"))
+ t.Setenv("XDG_CONFIG_HOME", t.TempDir())
+ t.Setenv("XDG_CACHE_HOME", t.TempDir())
+ mux := http.NewServeMux()
+ providerRoutes(mux, nil)
+ post := func(body string) {
+ t.Helper()
+ w := httptest.NewRecorder()
+ mux.ServeHTTP(w, httptest.NewRequest("POST", "/api/provider/save", strings.NewReader(body)))
+ if w.Code != 200 {
+ t.Fatalf("%d %s", w.Code, w.Body)
+ }
+ }
+ type model struct {
+ ID string `json:"id"`
+ On bool `json:"on"`
+ Best bool `json:"best"`
+ }
+ card := func() (best bool, on, newest []string) {
+ t.Helper()
+ w := httptest.NewRecorder()
+ mux.ServeHTTP(w, httptest.NewRequest("GET", "/api/providers", nil))
+ var got struct {
+ Providers []struct {
+ ID string `json:"id"`
+ BestInFamily bool `json:"bestInFamily"`
+ Models []model `json:"models"`
+ } `json:"providers"`
+ }
+ if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
+ t.Fatal(err)
+ }
+ for _, p := range got.Providers {
+ if p.ID != "relay" {
+ continue
+ }
+ for _, m := range p.Models {
+ if m.On {
+ on = append(on, m.ID)
+ }
+ if m.Best {
+ newest = append(newest, m.ID)
+ }
+ }
+ return p.BestInFamily, on, newest
+ }
+ t.Fatal("relay not listed")
+ return
+ }
+
+ const chat = "http://127.0.0.1:1/v1"
+ post(`{"id":"relay","name":"Relay","key":"sk-r","chat":"` + chat + `","new":true}`)
+ ms := []catalog.Model{{ID: "gemini-3.5-flash"}, {ID: "gemini-2.5-flash"}, {ID: "gemini-3.1-pro-preview"}, {ID: "gemini-2.5-pro"}, {ID: "gemini-3.5-flash-lite"}}
+ if err := catalog.SaveLive("relay", chat, ms); err != nil {
+ t.Fatal(err)
+ }
+ newestWant := []string{"gemini-3.5-flash", "gemini-3.1-pro-preview", "gemini-3.5-flash-lite"}
+ if best, on, newest := card(); best || len(on) != 5 || !slices.Equal(newest, newestWant) {
+ t.Fatalf("before: best %v on %v newest %v", best, on, newest)
+ }
+
+ post(`{"id":"relay","from":"relay","name":"Relay","key":"","chat":"` + chat + `","models":[],"noModels":false,"bestInFamily":true,"headers":{}}`)
+ if best, on, _ := card(); !best || !slices.Equal(on, newestWant) {
+ t.Fatalf("best: %v on %v", best, on)
+ }
+
+ // a save that doesn't name it (another editor's, the CLI's) keeps it
+ post(`{"id":"relay","from":"relay","name":"Relay","key":"","chat":"` + chat + `","headers":{}}`)
+ if best, on, _ := card(); !best || !slices.Equal(on, newestWant) {
+ t.Errorf("not named: best %v on %v", best, on)
+ }
+
+ // Vendor's list: the editor sends it false
+ post(`{"id":"relay","from":"relay","name":"Relay","key":"","chat":"` + chat + `","models":[],"noModels":false,"bestInFamily":false,"headers":{}}`)
+ if best, on, _ := card(); best || len(on) != 5 {
+ t.Errorf("vendor's list: best %v on %v", best, on)
+ }
+
+ // a pick clears it, even sent with it
+ post(`{"id":"relay","from":"relay","name":"Relay","key":"","chat":"` + chat + `","models":["gemini-2.5-pro"],"noModels":false,"bestInFamily":true,"headers":{}}`)
+ if p, _ := provider.Find("relay"); p.BestInFamily {
+ t.Error("a pick kept Best in family")
+ }
+ if best, on, _ := card(); best || !slices.Equal(on, []string{"gemini-2.5-pro"}) {
+ t.Errorf("picked: best %v on %v", best, on)
+ }
+}
diff --git a/internal/gui/providers.go b/internal/gui/providers.go
index 399c8c433..4260b9532 100644
--- a/internal/gui/providers.go
+++ b/internal/gui/providers.go
@@ -42,6 +42,7 @@ type modelJSON struct {
ImageSet bool `json:"imageSet,omitempty"` // the user said so, rather than its vendor
Own bool `json:"ownImages,omitempty"` // its vendor's answer, which a staged Restore default shows
On bool `json:"on"` // exposed to agents
+ Best bool `json:"best,omitempty"` // the newest of its family in the list: what Best in family serves (provider.NewestInFamily)
Context int `json:"context,omitempty"` // the window agents are told: the user's, else Listed
Output int `json:"output,omitempty"` // the reply limit agents are told: provider.ReplyLimit within Context (provider.OutputWithin)
Listed int `json:"listed,omitempty"` // its window before the user's: its vendor's list's, else models.dev's
@@ -253,6 +254,9 @@ type providerJSON struct {
HiddenDrawers []string `json:"hiddenDrawers,omitempty"`
Unlisted bool `json:"unlisted"` // its models serve only through routing groups
NoModels bool `json:"noModels"` // Select none: none of its models served (#1818)
+ // Best in family: with nothing picked, only the newest model of each
+ // family it lists is served (provider.Provider.BestInFamily)
+ BestInFamily bool `json:"bestInFamily"`
// Groups are the routing groups ("group/<id>") each of its models is
// in, by model id: what an unlisted one is still used through, and the
// editor names those in none
@@ -609,7 +613,7 @@ func providerInfoWith(p provider.Provider, agents []agentUse, desktop map[string
Catalog: p.Catalog, Website: p.Website, KeysURL: p.KeysURL,
Proxy: p.Proxy, AccountProxies: p.AccountProxies, AccountModels: p.AccountModels, AccountCaps: p.AccountCaps, AccountWindowCaps: p.AccountWindowCaps, AccountNames: p.AccountNames, Headers: p.Headers, ExtraBody: p.ExtraBody, ReplyHeaders: p.ReplyHeaders, Searches: p.Searches, Cline: p.ClinePinnable(), PinUpstream: p.PinUpstream, Unredacted: p.Unredacted, InsecureTLS: p.InsecureTLS, TakesInsecureTLS: p.TakesInsecureTLS(), LimitRestOff: p.LimitRestOff, NativeCompaction: p.NativeCompaction, CarriesCompaction: p.CarriesCompaction(), PassUserAgent: p.PassUserAgent, OwnClient: p.OwnClient(), AuthHeader: p.AuthHeader, BothAuth: p.BothAuth(), BalanceURL: p.BalanceURL, BalancePath: p.BalancePath, BalanceMethod: p.BalanceMethod, ModelsURL: p.ModelsURL,
Ready: p.Ready(), Chosen: p.Picks(), Models: []modelJSON{}, Agents: []providerAgent{},
- Fallback: p.Fallback, Routing: p.Routing, Sink: p.Sink, Affinity: p.Affinity, KeepLogin: p.KeepLogin, KeepLoginAs: p.KeepLoginAs, SwitchOnly: p.SwitchOnly, CapStop: p.CapStop, CapCareful: p.CapCareful, Unlisted: p.Unlisted, NoModels: p.ServesNone(), Off: p.Off, Contexts: p.Contexts,
+ Fallback: p.Fallback, Routing: p.Routing, Sink: p.Sink, Affinity: p.Affinity, KeepLogin: p.KeepLogin, KeepLoginAs: p.KeepLoginAs, SwitchOnly: p.SwitchOnly, CapStop: p.CapStop, CapCareful: p.CapCareful, Unlisted: p.Unlisted, NoModels: p.ServesNone(), BestInFamily: p.BestInFamily && len(p.Models) == 0 && !p.NoModels, Off: p.Off, Contexts: p.Contexts,
MaxConcurrency: p.MaxConcurrency, PluginConcurrency: p.PluginConcurrency(), PriceRate: p.PriceRate,
AccountConcurrency: p.AccountConcurrency, QueueLimit: p.QueueLimit, QueueWait: p.QueueWait, MaxRPM: p.MaxRPM,
Outputs: provider.OutputsOf(p.ID), Compacts: provider.CompactsOf(p.ID),
@@ -726,6 +730,11 @@ func providerInfoWith(p provider.Provider, agents []agentUse, desktop map[string
for _, m := range p.Exposed() {
exposed[m.ID] = true
}
+ avail := p.Available()
+ newest := map[string]bool{}
+ for _, m := range p.NewestInFamily(avail) {
+ newest[m.ID] = true
+ }
seen := map[string]bool{}
names, kept := p.ModelNames(), p.ModelEfforts()
held := settings.Load()
@@ -751,7 +760,7 @@ func providerInfoWith(p provider.Provider, agents []agentUse, desktop map[string
images = said
}
window := p.WindowOf(m)
- j := modelJSON{ID: m.ID, Name: m.Name, Efforts: provider.EffortsOf(m), On: on, Context: window, Output: provider.OutputWithin(window, p.ReplyLimitIn(m, set)), Listed: provider.ListedWindow(m), Max: m.MaxContext, Free: m.Free, Rate: m.Rate, RateWas: m.RateWas, Images: images, ImageSet: imageSet, Own: own}
+ j := modelJSON{ID: m.ID, Name: m.Name, Efforts: provider.EffortsOf(m), On: on, Context: window, Output: provider.OutputWithin(window, p.ReplyLimitIn(m, set)), Listed: provider.ListedWindow(m), Max: m.MaxContext, Free: m.Free, Rate: m.Rate, RateWas: m.RateWas, Images: images, ImageSet: imageSet, Own: own, Best: newest[m.ID]}
if i := slices.IndexFunc(most, func(c catalog.Model) bool { return c.ID == m.ID }); j.Max == 0 && i >= 0 {
j.Max = most[i].MaxContext
}
@@ -798,7 +807,7 @@ func providerInfoWith(p provider.Provider, agents []agentUse, desktop map[string
}
return j
}
- for _, m := range p.Available() {
+ for _, m := range avail {
seen[m.ID] = true
out.Models = append(out.Models, named(m, exposed[m.ID]))
}
@@ -1300,6 +1309,9 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
// NoModels, for save: the editor's Select none, kept with no
// model picked (#1818); a save that leaves it out keeps it
NoModels *bool `json:"noModels"`
+ // BestInFamily, for save: the editor's Best in family, kept
+ // with no model picked; a save that leaves it out keeps it
+ BestInFamily *bool `json:"bestInFamily"`
}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
fail(rw, err)
@@ -1309,6 +1321,9 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
if req.NoModels != nil {
in.NoModels = *req.NoModels
}
+ if req.BestInFamily != nil {
+ in.BestInFamily = *req.BestInFamily
+ }
if req.Routing != nil {
in.Routing = *req.Routing
}
@@ -1400,6 +1415,7 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
pr.Key, pr.Models, pr.Fallback, pr.Headers, pr.BalanceToken, pr.Contexts = in.Key, in.Models, in.Fallback, in.Headers, in.BalanceToken, in.Contexts
pr.ZhipuTeam = in.ZhipuTeam
pr.NoModels = in.NoModels
+ pr.BestInFamily = in.BestInFamily
pr.ExtraBody = in.ExtraBody
pr.ReplyHeaders = in.ReplyHeaders
pr.SecretAccessKey = in.SecretAccessKey
@@ -1640,6 +1656,10 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
if req.NoModels == nil && old != nil {
in.NoModels = old.NoModels
}
+ // and Best in family (normalize drops it under a pick)
+ if req.BestInFamily == nil && old != nil {
+ in.BestInFamily = old.BestInFamily
+ }
// a Volcengine access key likewise: its ID kept when left
// out or sent blank (an editor opened before the key was
// given sends ""), its Secret when sent blank, unless the
diff --git a/internal/gui/tests/provider-best-in-family.test.cjs b/internal/gui/tests/provider-best-in-family.test.cjs
new file mode 100644
index 000000000..91dc5cba4
--- /dev/null
+++ b/internal/gui/tests/provider-best-in-family.test.cjs
@@ -0,0 +1,140 @@
+// Run with Node's test runner and Playwright on the module path; see README.md.
+// Best in family is the models control's fourth option (Steven on
+// Discord): with nothing picked, only the newest model of each family the
+// vendor lists is served. The editor draws those (m.best, as
+// /api/providers says) dashed and the older ones as left out, says so in
+// its hint, saves it as bestInFamily with no picks and opens again on it.
+// Vendor's list and Usage only turn it off, and Picked only from it starts
+// from the newest ones. A provider saved before it opens on Vendor's list.
+// In every language, Chromium and WebKit, at 1100 and 420 wide.
+const assert = require("node:assert/strict");
+const fs = require("node:fs/promises");
+const path = require("node:path");
+const { test } = require("node:test");
+const { chromium, webkit } = require("playwright");
+
+const assets = path.resolve(__dirname, "../assets");
+const fetched = new Date(Date.now() - 3600e3).toISOString();
+const newest = ["claude-opus-5-5", "claude-sonnet-5-5"], older = ["claude-opus-4-8", "claude-sonnet-4-5"];
+const models = (on) => ["claude-opus-5-5", "claude-sonnet-5-5", "claude-opus-4-8", "claude-sonnet-4-5"].map((id) => ({ id, name: id, on: on(id), best: newest.includes(id) }));
+const base = {
+ icon: "generic", responses: "", anthropic: "", catalog: "", chosen: [], fetched, agents: [], fallback: [], headers: {},
+ key: { set: true, masked: "sk-…one" }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "",
+};
+// one saved before Best in family, and one saved with it
+const plain = { ...base, id: "plain", name: "Plain", host: "plain.example.com", chat: "https://plain.example.com/v1", models: models(() => true) };
+const best = { ...base, id: "best", name: "Best", host: "best.example.com", chat: "https://best.example.com/v1", bestInFamily: true, exposed: 2, models: models((id) => newest.includes(id)) };
+
+function serve(lang, saves) {
+ const providers = { providers: [plain, best], presets: [], excluded: [], gateway: { running: true, window: true } };
+ const state = { agents: [], profiles: [], settings: { lang, theme: "light" } };
+ return async (route) => {
+ const req = route.request(), url = new URL(req.url());
+ const json = (data) => route.fulfill({ json: data });
+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
+ if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
+ if (url.pathname === "/api/state") return json(state);
+ if (url.pathname === "/api/plugins") return json({ plugins: [] });
+ if (url.pathname === "/api/providers") return json(providers);
+ if (url.pathname === "/api/provider/save") { saves.push(req.postDataJSON()); return json(providers); }
+ if (url.pathname === "/api/groups") return json({ groups: [] });
+ if (url.pathname.startsWith("/api/")) return json({});
+ const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
+ const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
+ await route.fulfill({ body: await fs.readFile(file), contentType });
+ };
+}
+
+// hint: the editor's hint under Best in family
+const words = {
+ en: { save: "Save", list: "Vendor's list", picked: "Picked only", best: "Best in family", usage: "Usage only", hint: "Best in family: agents see the newest model of each family" },
+ zh: { save: "保存", list: "供应商列表", picked: "仅所选", best: "每系最新", usage: "仅看用量", hint: "每系最新:Agent 看到它列表里每个系列最新的模型" },
+ "zh-TW": { save: "儲存", list: "供應商列表", picked: "僅所選", best: "每系最新", usage: "僅看用量", hint: "每系最新:Agent 看到它列表裡每個系列最新的模型" },
+ ja: { save: "保存", list: "ベンダーのリスト", picked: "選択したもののみ", best: "系列の最新のみ", usage: "使用量のみ", hint: "系列の最新のみ:エージェントには一覧の各系列の最新モデル" },
+ de: { save: "Speichern", list: "Liste des Anbieters", picked: "Nur gewählte", best: "Neuestes je Familie", usage: "Nur Nutzung", hint: "Neuestes je Familie: Agents sehen das neueste Modell jeder Familie" },
+};
+
+for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
+ for (const lang of Object.keys(words)) {
+ const w = words[lang];
+ for (const width of [1100, 420]) {
+ test(`${engine} ${lang} ${width}: Best in family serves the newest of each family`, async (t) => {
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
+ const page = await (await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" })).newPage();
+ t.after(async () => {
+ if (process.env.ARTIFACT_DIR) {
+ await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
+ await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-provider-best-in-family.png`) });
+ }
+ await browser.close();
+ });
+ page.setDefaultTimeout(5000);
+ const errors = [];
+ page.on("pageerror", (e) => errors.push(e.message));
+ const saves = [];
+ await page.route("**/*", serve(lang, saves));
+ await page.goto("http://magpie.test/?view=providers");
+ const editor = page.locator("#modal:not([hidden]) .editor");
+ const chip = (id) => editor.locator(".mchips .mchip", { hasText: id });
+ const cls = (id) => chip(id).evaluate((c) => [c.classList.contains("on"), c.classList.contains("auto")]);
+ const serves = async () => {
+ const seg = editor.locator(".mserves");
+ const box = await seg.boundingBox(), ed = await editor.boundingBox();
+ assert.ok(box && box.x >= ed.x - 1 && box.x + box.width <= ed.x + ed.width + 1, "the control fits the editor");
+ // every option's label shows whole
+ for (const o of await seg.locator(".opt").all()) assert.ok(await o.evaluate((b) => b.scrollWidth <= b.clientWidth + 1), "an option's label fits");
+ return seg.locator(".opt.on").innerText();
+ };
+ const save = async () => {
+ const n = saves.length;
+ await editor.locator(".bar").getByRole("button", { name: w.save, exact: true }).click();
+ for (let i = 0; i < 60 && saves.length === n; i++) await page.waitForTimeout(50);
+ assert.equal(saves.length, n + 1, "saved");
+ await page.locator("#modal:not([hidden]) .editor").waitFor({ state: "detached" }).catch(() => {});
+ return saves[n];
+ };
+
+ // one saved before it opens on the vendor's list, every model dashed
+ await page.locator(".row.provider", { hasText: "Plain" }).click();
+ await chip("claude-opus-4-8").waitFor();
+ assert.equal(await serves(), w.list);
+ assert.equal(await editor.locator(".mserves .opt").count(), 4);
+ for (const id of [...newest, ...older]) assert.deepEqual(await cls(id), [false, true], id + " on the vendor's list");
+ // Best in family: the newest dashed, the older ones left out
+ await editor.locator(".mserves .opt[data-serves=best]").click();
+ assert.equal(await serves(), w.best);
+ for (const id of newest) assert.deepEqual(await cls(id), [false, true], id + " served");
+ for (const id of older) assert.deepEqual(await cls(id), [false, false], id + " left out");
+ await editor.getByText(w.hint, { exact: false }).waitFor();
+ if (process.env.ARTIFACT_DIR) await editor.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-provider-best-in-family-editor.png`) });
+ let sent = await save();
+ assert.equal(sent.bestInFamily, true, "bestInFamily sent");
+ assert.equal(sent.noModels, false);
+ assert.deepEqual(sent.models || [], []);
+
+ // one saved with it opens on it; Picked only starts from the newest
+ await page.locator(".row.provider", { hasText: "Best" }).click();
+ await chip("claude-opus-4-8").waitFor();
+ assert.equal(await serves(), w.best);
+ for (const id of older) assert.deepEqual(await cls(id), [false, false], id + " left out");
+ await editor.getByText(w.hint, { exact: false }).waitFor();
+ await editor.locator(".mserves .opt[data-serves=picked]").click();
+ assert.equal(await serves(), w.picked);
+ for (const id of newest) assert.deepEqual(await cls(id), [true, false], id + " picked");
+ // the older ones aren't picked (Picked only folds unpicked ones away)
+ for (const id of older) assert.equal(await editor.locator(".mchips .mchip.on", { hasText: id }).count(), 0, id + " not picked");
+ // Usage only, then Vendor's list: neither keeps it
+ await editor.locator(".mserves .opt[data-serves=none]").click();
+ assert.equal(await serves(), w.usage);
+ await editor.locator(".mserves .opt[data-serves=list]").click();
+ assert.equal(await serves(), w.list);
+ for (const id of [...newest, ...older]) assert.deepEqual(await cls(id), [false, true], id + " vendor's list again");
+ assert.equal(await editor.getByText(w.hint, { exact: false }).count(), 0);
+ sent = await save();
+ assert.equal(sent.bestInFamily, false, "Vendor's list sends it off");
+ assert.equal(sent.noModels, false);
+ assert.deepEqual(errors, []);
+ });
+ }
+ }
+}
diff --git a/internal/provider/account_models.go b/internal/provider/account_models.go
index 0cdfbd1d0..db6352a54 100644
--- a/internal/provider/account_models.go
+++ b/internal/provider/account_models.go
@@ -208,10 +208,10 @@ func SetModels(id string, models []string) error {
return err
}
ms := normalModels(models)
- if slices.Equal(ms, normalModels(p.Models)) && !p.ServesNone() {
+ if slices.Equal(ms, normalModels(p.Models)) && !p.ServesNone() && !p.BestInFamily {
return nil
}
- p.Models, p.NoModels = ms, false
+ p.Models, p.NoModels, p.BestInFamily = ms, false, false
return Save(*p)
}
diff --git a/internal/provider/autolist.go b/internal/provider/autolist.go
index c01eaf25d..beda52f1b 100644
--- a/internal/provider/autolist.go
+++ b/internal/provider/autolist.go
@@ -237,7 +237,7 @@ func takeMatching(id string, isNew func(string) bool) ([]string, error) {
q := &f.Providers[i]
// new ones first, as the vendor's list and withNewlyListed have them
q.Models = append(slices.Clone(taken), served...)
- q.NoModels = false
+ q.NoModels, q.BestInFamily = false, false
// picked from the list as it is now: one it lists later and no rule
// matches stays out, unless the picks hold every model
q.PickedFrom = nil
diff --git a/internal/provider/best_in_family_test.go b/internal/provider/best_in_family_test.go
new file mode 100644
index 000000000..290efb62d
--- /dev/null
+++ b/internal/provider/best_in_family_test.go
@@ -0,0 +1,131 @@
+package provider
+
+import (
+ "encoding/json"
+ "os"
+ "slices"
+ "testing"
+
+ "github.com/yetone/magpie/internal/catalog"
+)
+
+// Best in family (Steven on Discord): with nothing picked, only the newest
+// model of each family the vendor lists is served, and one it lists later
+// takes the old one's place by itself. A request naming an older one is
+// still served, as one naming a model left unpicked is; a pick or Select
+// none clears it, and a providers.json without it reads as before.
+func TestBestInFamilyExposed(t *testing.T) {
+ azureHome(t)
+ ids := func(ms []catalog.Model) []string {
+ var out []string
+ for _, m := range ms {
+ out = append(out, m.ID)
+ }
+ return out
+ }
+ list := func(ids ...string) {
+ t.Helper()
+ var ms []catalog.Model
+ for _, id := range ids {
+ ms = append(ms, catalog.Model{ID: id})
+ }
+ if err := catalog.SaveLive("fam", "https://fam.example.invalid/v1", ms); err != nil {
+ t.Fatal(err)
+ }
+ }
+ find := func() Provider {
+ t.Helper()
+ p, err := Find("fam")
+ if err != nil {
+ t.Fatal(err)
+ }
+ return *p
+ }
+ p := Provider{ID: "fam", Name: "Fam", Key: "sk-x", Chat: "https://fam.example.invalid/v1"}
+ if err := Save(p); err != nil {
+ t.Fatal(err)
+ }
+ list("claude-opus-5-5", "claude-sonnet-5-5", "claude-opus-4-8", "claude-haiku-5-5", "claude-sonnet-4-5-20250929", "claude-haiku-4-5")
+ all := []string{"claude-opus-5-5", "claude-sonnet-5-5", "claude-opus-4-8", "claude-haiku-5-5", "claude-sonnet-4-5-20250929", "claude-haiku-4-5"}
+
+ // a file saved before it: the vendor's list, as ever
+ if got := find(); got.BestInFamily || !slices.Equal(ids(got.Exposed()), all) {
+ t.Fatalf("before: best %v exposed %v", got.BestInFamily, ids(got.Exposed()))
+ }
+ raw, err := os.ReadFile(Path())
+ if err != nil {
+ t.Fatal(err)
+ }
+ var file map[string]any
+ if err := json.Unmarshal(raw, &file); err != nil {
+ t.Fatal(err)
+ }
+ if containsKey(file, "bestInFamily") {
+ t.Fatalf("a provider saved without it wrote bestInFamily: %s", raw)
+ }
+
+ p.BestInFamily = true
+ if err := Save(p); err != nil {
+ t.Fatal(err)
+ }
+ want := []string{"claude-opus-5-5", "claude-sonnet-5-5", "claude-haiku-5-5"}
+ if got := find(); !got.BestInFamily || !slices.Equal(ids(got.Exposed()), want) {
+ t.Fatalf("best: %v exposed %v, want %v", got.BestInFamily, ids(got.Exposed()), want)
+ }
+ if got := ids(find().NewestInFamily(find().Available())); !slices.Equal(got, want) {
+ t.Errorf("NewestInFamily = %v, want %v", got, want)
+ }
+ // an older one named by its provider/model id is still served, as an
+ // unpicked one is under Picked only
+ if q, m, ok := Resolve("fam/claude-opus-4-8"); !ok || q.ID != "fam" || m != "claude-opus-4-8" {
+ t.Errorf("fam/claude-opus-4-8: %v %q %v", q.ID, m, ok)
+ }
+ // Opus 5.6 listed later takes Opus 5.5's place, with nothing saved
+ list("claude-opus-5-6", "claude-opus-5-5", "claude-sonnet-5-5", "claude-opus-4-8", "claude-haiku-5-5")
+ if got := ids(find().Exposed()); !slices.Equal(got, []string{"claude-opus-5-6", "claude-sonnet-5-5", "claude-haiku-5-5"}) {
+ t.Errorf("after Opus 5.6 is listed: %v", got)
+ }
+ // a save of something else keeps it
+ q := find()
+ q.Name = "Fam renamed"
+ if err := Save(q); err != nil {
+ t.Fatal(err)
+ }
+ if !find().BestInFamily {
+ t.Error("a rename dropped Best in family")
+ }
+ // a pick clears it
+ if err := SetModels("fam", []string{"claude-opus-4-8"}); err != nil {
+ t.Fatal(err)
+ }
+ if got := find(); got.BestInFamily || !slices.Equal(ids(got.Exposed()), []string{"claude-opus-4-8"}) {
+ t.Errorf("a pick: best %v exposed %v", got.BestInFamily, ids(got.Exposed()))
+ }
+ // and so does Select none
+ q = find()
+ q.Models, q.NoModels, q.BestInFamily = nil, true, true
+ if err := Save(q); err != nil {
+ t.Fatal(err)
+ }
+ if got := find(); got.BestInFamily || !got.ServesNone() {
+ t.Errorf("Select none: best %v none %v", got.BestInFamily, got.ServesNone())
+ }
+}
+
+func containsKey(v any, key string) bool {
+ switch x := v.(type) {
+ case map[string]any:
+ for k, e := range x {
+ if k == key || containsKey(e, key) {
+ return true
+ }
+ }
+ case []any:
+ for _, e := range x {
+ if containsKey(e, key) {
+ return true
+ }
+ }
+ }
+ return false
+}
diff --git a/internal/provider/codex_models.go b/internal/provider/codex_models.go
index 6bd05df6f..0c0d6e127 100644
--- a/internal/provider/codex_models.go
+++ b/internal/provider/codex_models.go
@@ -634,7 +634,8 @@ func buildCodexListTag(kind string) string {
// A provider switched off picks nothing, as it serves no agent anything
// (Provider.Off): its picks are kept for when it is switched on again and
// are not a narrowing now. Usage only narrows the visible native list to
-// none, as it does the general catalog; codexModels keeps hidden jobs.
+// none, as it does the general catalog; codexModels keeps hidden jobs. Best
+// in family narrows it to the newest of each family the account lists.
func CodexNativePicked() (map[string]bool, bool) {
p, ok := find(All(), "codex")
if !ok || p.Off {
@@ -643,6 +644,15 @@ func CodexNativePicked() (map[string]bool, bool) {
if p.ServesNone() {
return nil, true
}
+ if len(p.Models) == 0 && p.BestInFamily {
+ // Best in family: the newest of each family the account lists
+ keep := map[string]bool{}
+ for _, m := range catalog.BestInFamily(p.Available()) {
+ keep[m.ID] = true
+ }
+ // with no list known, the account's own is left whole
+ return keep, len(keep) > 0
+ }
if len(p.Models) == 0 {
return nil, false
}
diff --git a/internal/provider/models.go b/internal/provider/models.go
index 8ae16ad7d..56e6b757d 100644
--- a/internal/provider/models.go
+++ b/internal/provider/models.go
@@ -1504,8 +1504,9 @@ func (p Provider) ServesNone() bool { return p.NoModels && len(p.Models) == 0 }
func (p Provider) waitsForPicks() bool { return len(p.Models) == 0 && len(p.Delisted) > 0 }
// Exposed lists the models magpie offers to agents for this provider: the
-// user's picks; else the preset's; else everything, when that is few; none
-// after Select none (ServesNone).
+// user's picks; else the preset's; else everything, when that is few, the
+// newest of each family only under Best in family; none after Select none
+// (ServesNone).
func (p Provider) Exposed() []catalog.Model {
if p.ServesNone() || p.waitsForPicks() {
return nil
@@ -1557,7 +1558,11 @@ func (p Provider) Exposed() []catalog.Model {
}
// a model listed on none of the APIs the provider has a URL for is
// left out before the first 24 are taken (#2094)
- avail = slices.DeleteFunc(slices.Clone(avail), func(m catalog.Model) bool { return p.NoAPIFor(m.ID) })
+ avail = p.servable(avail)
+ // Best in family: the newest of each family the list has
+ if p.BestInFamily {
+ avail = catalog.BestInFamily(avail)
+ }
// another magpie's list is already the models its user exposed
if len(avail) <= manyModels || p.IsRemoteMagpie() {
return avail
@@ -1568,6 +1573,19 @@ func (p Provider) Exposed() []catalog.Model {
return avail[:manyModels]
}
+// servable is avail less the models NoAPIFor leaves out.
+func (p Provider) servable(avail []catalog.Model) []catalog.Model {
+ return slices.DeleteFunc(slices.Clone(avail), func(m catalog.Model) bool { return p.NoAPIFor(m.ID) })
+}
+
+// NewestInFamily is the models Best in family would serve of avail, the
+// vendor's list (Available), before the first 24 are taken: the newest of
+// each family among those it can be asked for (catalog.BestInFamily),
+// whichever mode is on, so the editor can draw them before it is saved.
+func (p Provider) NewestInFamily(avail []catalog.Model) []catalog.Model {
+ return catalog.BestInFamily(p.servable(avail))
+}
+
// NoAPIFor says the provider has a URL for none of the APIs the vendor's
// list serves model on (or the one the user set for it): a relay's Claude
// listed on /messages alone, at a provider given only a chat URL. Agents
diff --git a/internal/provider/provider.go b/internal/provider/provider.go
index 13a615a77..184d870b0 100644
--- a/internal/provider/provider.go
+++ b/internal/provider/provider.go
@@ -422,6 +422,14 @@ type Provider struct {
// are still read and shown. Without it, no picks is the vendor's list
// as ever, so a file saved before it reads as it did. A pick clears it.
NoModels bool `json:"noModels,omitempty"`
+ // BestInFamily is the editor's Best in family (Steven on Discord): with
+ // no Models picked, of the vendor's list only the newest model of each
+ // family is served (catalog.BestInFamily), so Opus 5.6, once listed,
+ // takes Opus 5.5's place by itself. A request that names another of its
+ // models is still served, as one that names a model left unpicked is. A
+ // pick or Select none clears it (normalize); a file without it reads as
+ // the vendor's list, as before.
+ BestInFamily bool `json:"bestInFamily,omitempty"`
// PickedFrom are the models the vendor listed when Models were saved: one
// listed since is served beside picks that held every one listed then
// (withNewlyListed), and one listed then and left unpicked stays out.
@@ -767,7 +775,7 @@ func withPicks(a, pk Provider) Provider {
a.PickedFrom, a.Delisted = pk.PickedFrom, pk.Delisted
a.Models, a.Unlisted, a.Off, a.Fallback, a.Routing, a.Affinity, a.KeepLogin, a.KeepLoginAs, a.Contexts, a.Family = pk.Models, pk.Unlisted, pk.Off, pk.Fallback, pk.Routing, pk.Affinity, pk.KeepLogin, pk.KeepLoginAs, pk.Contexts, pk.Family
a.SwitchOnly = pk.SwitchOnly
- a.Sink, a.NoModels = pk.Sink, pk.NoModels
+ a.Sink, a.NoModels, a.BestInFamily = pk.Sink, pk.NoModels, pk.BestInFamily
a.NativeCompaction = pk.NativeCompaction
a.PromptAsWritten = pk.PromptAsWritten
a.Proxy, a.AccountProxies, a.AccountModels = pk.Proxy, pk.AccountProxies, pk.AccountModels
@@ -914,7 +922,7 @@ func Save(p Provider) error {
if p.ID == "kiro" {
key = p.Key
}
- p = Provider{ID: p.ID, Key: key, Models: p.Models, NoModels: p.NoModels, PickedFrom: p.PickedFrom, Delisted: p.Delisted, Unlisted: p.Unlisted, HiddenDrawers: p.HiddenDrawers, Off: p.Off, Fallback: p.Fallback, Routing: p.Routing, Sink: p.Sink, Affinity: p.Affinity, KeepLogin: p.KeepLogin, KeepLoginAs: p.KeepLoginAs, SwitchOnly: p.SwitchOnly, Contexts: p.Contexts, Family: p.Family, Proxy: p.Proxy, AccountProxies: p.AccountProxies, AccountModels: p.AccountModels, AccountCaps: p.AccountCaps, AccountWindowCaps: p.AccountWindowCaps, CapStop: p.CapStop, CapCareful: p.CapCareful, AccountNames: p.AccountNames, MaxConcurrency: p.MaxConcurrency, AccountConcurrency: p.AccountConcurrency, QueueLimit: p.QueueLimit, QueueWait: p.QueueWait, MaxRPM: p.MaxRPM, PriceRate: p.PriceRate, QuotaRest: p.QuotaRest, QuotaResetAt: p.QuotaResetAt, RestCap: p.RestCap, PinUpstream: p.PinUpstream, NativeCompaction: p.NativeCompaction, PromptAsWritten: p.PromptAsWritten, Hidden: hiddenAccount(p.ID), Quiet: quietAccount(p.ID), Tucked: tuckedAccount(p.ID)}
+ p = Provider{ID: p.ID, Key: key, Models: p.Models, NoModels: p.NoModels, BestInFamily: p.BestInFamily, PickedFrom: p.PickedFrom, Delisted: p.Delisted, Unlisted: p.Unlisted, HiddenDrawers: p.HiddenDrawers, Off: p.Off, Fallback: p.Fallback, Routing: p.Routing, Sink: p.Sink, Affinity: p.Affinity, KeepLogin: p.KeepLogin, KeepLoginAs: p.KeepLoginAs, SwitchOnly: p.SwitchOnly, Contexts: p.Contexts, Family: p.Family, Proxy: p.Proxy, AccountProxies: p.AccountProxies, AccountModels: p.AccountModels, AccountCaps: p.AccountCaps, AccountWindowCaps: p.AccountWindowCaps, CapStop: p.CapStop, CapCareful: p.CapCareful, AccountNames: p.AccountNames, MaxConcurrency: p.MaxConcurrency, AccountConcurrency: p.AccountConcurrency, QueueLimit: p.QueueLimit, QueueWait: p.QueueWait, MaxRPM: p.MaxRPM, PriceRate: p.PriceRate, QuotaRest: p.QuotaRest, QuotaResetAt: p.QuotaResetAt, RestCap: p.RestCap, PinUpstream: p.PinUpstream, NativeCompaction: p.NativeCompaction, PromptAsWritten: p.PromptAsWritten, Hidden: hiddenAccount(p.ID), Quiet: quietAccount(p.ID), Tucked: tuckedAccount(p.ID)}
} else {
p.AccountProxies = keyProxies(p) // a provider of keys proxies each key apart
if subscriptionID(p.ID) && !stored(p.ID) {
@@ -1369,6 +1377,9 @@ func normalize(p Provider) Provider {
if len(p.Models) > 0 {
p.NoModels = false // a pick is no longer Select none
}
+ if len(p.Models) > 0 || p.NoModels {
+ p.BestInFamily = false // nor Best in family
+ }
p.ZhipuTeam = p.ZhipuTeam.normal()
p.Vertex = p.Vertex.Normal()
if !p.IsVertex() {