A provider or group can be routed `free`. Seats whose model the vendor
serves at no cost to the allowance or credits go first, in listed order.
The rest follow, also in listed order. Free means the vendor's own
catalog.Model.Free word, or else a $0 list price on every count
(provider.FreeModel). A pool with no free model behaves as In order.
routes.Seat gains Free and Strategy gains ByFree. weighRouted works Free
out only for a strategy that weighs by it, so other routings never read
a model list for it.
It is wired through every list a routing appears in:
- both save whitelists;
- plugins/rotation's Builtin;
- app.js's ROUTINGS (appScriptBudget 1,269,000 → 1,271,000 for the
description) and the Routing page's options, hints and trace text;
- zh-TW, ja and de strings;
- the TUI's routings;
- the CLI's aliases (free, free-first).
Written by keeuu (issue #3054, three commits), squashed onto dee5c9d75
and reviewed:
- the harm checks were clean;
- FreeModel runs only for ByFree, so its Available() walk costs nothing
for other routings;
- accounts can list different models, so Free first means something for
a provider's own accounts too, not only for groups.
Run at this head:
- gofmt -l: clean.
- go vet: darwin (internal/routes, provider, gateway, cli, tui, gui);
GOOS=windows ./internal/...; GOOS=linux -tags nogui ./... — all clean.
- go test ./internal/routes ./internal/provider -run
'Free|Routing|Strateg|Builtin' ok; ./internal/gateway -run
'FreeFirst|Weigh|Routing' ok.
- Broken by hand: with FreeFirst returning paid before free,
internal/routes' Free tests and
TestFreeFirstGroupSpendsTheFreeMemberFirst go red. Restored, green.
- go test ./... -count=1 -timeout 45m, at load average ~460 from other
sessions: 62 packages ok, 3 red:
- internal/gui TestMainWindowCorners (#1936/#2645, AppKit window
killed at its deadline under load);
- internal/gateway TestClaudeAccountsSpentFallBackToCodex ("no
answer"): ok alone in 46s;
- internal/agent timed out at 45m inside TestSnowSmallModel (1s in):
the package is ok alone in 1519s.
- GUI, both engines (node --test, playwright 1.62.0), 23 files:
account-arrange, builtins, context-text, context-scroll-end,
context-window, group-member-weight, key-weight, rate-limited-sink,
routing-reset-deadline, routing-compaction, routing-key-windows,
routing-save, routing-sealed-task, routing-weight-chip, search-keys,
i18n-keys, panel-routing-pick, panel-routing-providers, panel-routing,
routing-columns, gui-de, gui-ja, gui-zh-tw. 230 of 236 pass.
routing-save (the 6/7 counts), routing-columns, i18n-keys and the three
language files are green.
- account-arrange "every mode" (#2200): red in both engines, alone,
and on origin/main dee5c9d75 too.
- builtins chromium "Plugins › Built-in" (#2960): a 5s wait for the
Plugins page. Red alone and on dee5c9d75 too; the webkit run checks
the new Routing strategies subtitle and passes.
- context-window and context-text, single cases in different
language/engine pairs on each run: 5s waits under load (#1544,
#2900). Untouched by this change.
Co-authored-by: keeuu <159448501+keeuu@users.noreply.github.com>