Entry.Provider was a Provider value, 1,328 of an Entry's 1,760 bytes,
copied into every model of every provider each time a catalog, an
agent's list or a routing group's entries were built. It is now a
*Provider: entriesOf and decide's list give every model of one provider
the same one (sharedEntry), and a group's entry points at its first
member's. It is read only; every place that hands it on as a value
(Resolve, CanFast, ownAgent, modelAllowed, …) dereferences it, so what
they get is a copy as before. entryFor keeps its signature for the one
model ServedEntryOf builds; offEntries' entries now carry their provider
too.
Measured on mote with the owner's real accounts (acctp sandbox, page
open for 2m32s, w40 = before, w41 = this, alternating):
- catalogOf's allocations 106 MB -> 67 MB, providerEntries' 88 -> 78 MB
- CPU at the page's settle mark 3.42/3.33 s -> 3.18/3.30 s
- live heap unchanged (76.3/76.1 -> 76.7/75.9 MB): the lists are
rebuilt, not kept, so the copies were churn for the GC, not held
Run: go build and go vet ./... and the tests compiled (go test -run ^$)
on mote; the full suite at this tree (d1e823d5f) on mica: 99 packages ok, 0 FAIL (agent 317s, gateway 972s, gui 188s, provider 220s, usage 56s).
MisakaNatsuxun (Discord, 10-23) set a custom OpenAI-compatible provider's
Advanced > Context window to 1M. Routing still showed 200K for
deepseek-v4.1-flash-free, and dsh was told contextWindow 200000.
Cause: WindowOf capped the provider-wide "*" window at ListedWindow(m)
(#2112, 273ab9c23). ListedWindow falls back to catalog.ContextOf, a guess
by model id from any vendor on models.dev. For a relay with no catalog of
its own, opencode's deepseek-v4.1-flash-free (200000) or Anthropic's
claude-sonnet-4-5 (200000) capped the user's 1M. WindowOf feeds Served,
so /v1/models, the Routing picker, the editor's model chips and every
agent config (dsh's contextWindow too) got 200K.
Fix: "*" is capped only by the provider's own word: catalog.Window
(m.Context, set from its live list, its own models.dev catalog or plan
models) and m.MaxContext. #2112's OpenCode Go case still caps, since that
catalog sets m.Context. A per-model entry already won and still does.
Siblings: Max output (replyLimit) already took the user's value over
m.Output and the catalog, on old and new (checked "*"=128000). Anthropic-
and Responses-type custom providers read the same WindowOf and are fixed
with it. Left alone: with no window set, OutputWithin still caps a
user's Max output at the guessed window.
Tests, each red on the old code (ListedWindow put back by hand):
- provider TestProviderWindowSetOverAnotherVendorsGuess: "map[*:1000000]:
claude-sonnet-4-5 told 200000, want 1000000"
- agent TestDshToldTheWindowSetForACustomProvider (opencode's
deepseek-v4.1-flash-free fixture, dshRouteConfig and
dshProviderLines): told contextWindow 200000
Sandbox HOME, fake OpenAI /models on 127.0.0.1:3481, relay "*"=1M:
- old binary: /v1/models relay/deepseek-v4.1-flash-free 200000,
relay/claude-sonnet-4-5 200000; connecting dsh wrote contextWindow
200000; no 1M on the Sonnet chip in the editor or the Routing picker.
- new binary (this tree, -tags dev): 1000000 for both, dsh config
written fresh says contextWindow 1000000 / maxTokens 32000 (ca4a1cde0's
cap at the model's output); Routing picker "DeepSeek V4.1 Flash Free
1M"; relay-a (anthropic), relay-r (responses) 1M; relay-lo "*"=128K
stays 128000.
Not tried: a real relay account, and dsh making a real request.
Run at 62cf0c76d (this tree on origin/main 032d88c13): gofmt -l clean;
go vet darwin, linux -tags nogui, windows clean; go test -tags nogui
-timeout 45m ./... : 69 ok, 19 no test files, no FAIL (agent 336s,
gateway 474s, gui 123s, provider 187s). GUI files in chromium and
webkit: context-picks 10/10, provider-advanced-fold 25/25,
provider-output-picks 2/2, compact-at 4/4, gui-ja 3/3, gui-zh-tw 3/3,
gui-de 3/3, i18n-keys 3/3.
OpenCode Go set to 512K for all its models (Contexts["*"]) told Claude
Code 512K for cat-jam-free too, whose window is 262144 (models.dev), so
Claude Code ran past the model's real window before compacting and the
vendor refused the request.
WindowOf now caps the "*" value at the model's own window when one is
known: the listed window (vendor list or models.dev), or the larger
max_context_window a model may be raised to (Codex's 872K), so a Codex
raised to 600K stays raised. A model with no known window takes the "*"
value as before, and a window set for the model itself is the user's
word and is told as set. The gateway's windowOf (fallback.go) reads the
served entry's window, which is WindowOf's, after a per-model value, so
the gateway's own fit uses the same number the agent is told.
Run:
- TestProviderWindowNoLargerThanTheModels: the models.dev bytes for
opencode-go cat-jam-free (262144) and a 1M model with "*" at 512000:
262144, 512000, 512000 for an unknown model, a per-model 400000 kept;
Codex 272K/872K with "*" 600K stays 600K, capped at a 400K max. FAILs
on the old WindowOf (cat-jam-free told 512000).
- gofmt -l; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
internal/provider and internal/gateway; go test -tags nogui
./internal/provider/ ./internal/gateway/.
Not tried: a real OpenCode Go account with Claude Code.