Commit Graph
8 Commits
Author SHA1 Message Date
yetone 7aad6a50ea provider: a window set for all of a custom provider's models wins over another vendor's guess
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.
2026-10-23 02:17:01 +08:00
yetone 273ab9c235 provider: a window set for all of a provider's models is no larger than a model's own (#2112)
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.
2026-10-14 15:34:16 +08:00
yetone 399e5db63d gui, groups: a group's editor sets the context agents are told — its largest model's, its smallest model's, or one typed (Mikan on Discord: 路由组可以支持自定义上下文长短或者支持用户选择按照上下文长度最短的供应商还是上下文长度最長的供应商吗?) — a group told agents its largest member's window (#712), and another could only be set from the CLI. The group editor now has a Context row under Slow to start: Largest model's (as before), Smallest model's, or Custom with a box (200k, 1m, 128000), its hint naming the window agents will be told from the members' own, redrawn as members are added or taken off; a length that isn't one says so and isn't saved. Smallest is kept as smallest (Context -1, ContextSmallest), worked out as the members change, so the agent compacts before any member would turn a conversation away; a conversation too long for one member still goes on to one with room. magpie group set <id> context=smallest|largest|272k does the same. zh, ja, de strings. TestContextSetByUser (smallest, then smallest after a member leaves) fails on the old code; TestApplyGroupPairs covers context=. group-context.test.cjs (WebKit, en and zh): Largest by default with no box, Smallest saves -1 and reopens so, Custom starts at the smallest member's, a bad length shows its error, 300k saves 300000 and reopens, Largest saves 0. group-first-token and group-patterns get a taller window, the editor having grown under the fixed footer; they, group-arrange, fold, member-off, member-fast, rate-limited-sink, routing-compact, manual, levels, steady, time, unlisted-models and settings-groups pass on WebKit. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-05 03:00:34 +08:00
yetone a11b74883e group: a routing group tells agents its largest member's context window, not its shortest's (#712, Moody-Sin on v0.1.779: Pi on group/deepseek showed 82.4%/200k, where the group's DeepSeek V4.1 Flash members hold 1M) — groupEntries took the smallest window any member had (since 09c635cf/c83e03d5, "otherwise its shortest model's"), and the group 腾讯DeepSeek has OpenCode Zen's deepseek-v4-flash-free among its ten members, which models.dev gives 200000 (the rest: deepseek-v4.1-flash 1000000 at WorkBuddy and OpenCode Go, muse-spark-1.3-contributor 1048576), so /v1/models, Pi's models.json and every agent's config said 200k and Pi compacted there. No commit changed this code lately; what brought the window down is that member: added to the group, or its figure on models.dev — which of the two is not known. The shortest made sense while a too-long conversation was never sent past the member it overflowed; since b5cfca54 (v0.1.771, #700) an overflow goes on to the members left not known to be too small for it (withRoom), and the agent is told to compact only when none has room, so the group's window is its largest member's. A context set on the group (magpie group set … context=) still wins, below the members' too; a length rule (ruledEntry) never lifts past the largest, so its comment says so. The CLI's and TUI's help say "largest model's". TestGroupToldItsLargestWindow (the reporter's members, one window unknown: old code 200000, new 1048576) and TestContextSetByUser (largest by default, a lower set one wins) fail on the old code and pass; TestRuleImages now expects the group's 1M. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried with the reporter's accounts: a conversation past 200k reaching the free member first costs it one refused request before the next member answers. The model tooltip in the Gateway page says so too: "Context: n tokens (the largest of its models')" / 上下文(组内模型中最大的), where it said the least. 2026-10-04 02:44:59 +08:00
yetone a2714f7506 claude: a Claude account's usage resets are read in the zone /usage names on Windows too, and the provider tests pass whole on Windows (goal: 插件订阅 provider 跟内置的所有逻辑都要一模一样, run on Windows and Linux) — Windows has no time zone database, so "resets Oct 1 at 3:30pm (Asia/Shanghai)" was read in the machine's own zone, hours off for anyone not in that zone; magpie now carries the database (time/tzdata). The provider tests set HOME but not USERPROFILE, which Windows takes the home from, so on Windows they read the test box's own agent sign-ins (Gemini models in a list, an extra provider, a Cursor version); every test home sets both now. Tests whose fake CLI is a shell script (Claude Code's auth status, codex --version, macOS's security) skip on Windows, as the fake devin did, and file mode bits go unchecked there. TestParseClaudeUsage fails on Windows without the change. On Windows and on Linux (WSL) the provider package passes whole, three times on Windows (15 failed before), the plugin package and the move/plugin/Grok/Devin/usage tests five times over on Linux. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-10-01 13:51:24 +08:00
yetone 315a19b6e2 providers: test that a subscription's context window set in its editor reaches the models agents are told of (#120) — Codex's 272K from the ChatGPT backend gives way to the 872K a user sets on the Codex account, through the account's save 2026-09-28 00:28:53 +08:00
yetone 1d064efe4d provider: TestContextSetByUser gives the config dir a place, so the Devin CLI a saved group asks writes its config there, not into internal/provider/devin 2026-09-26 23:02:05 +08:00
yetone c83e03d5c7 provider: how long a request a model takes can be set — magpie provider set <id> context=272k (all its models) or context.<model>=1m, and magpie group set <id> context=… for a group, which otherwise takes its shortest model's; agents are told it (Pi's contextWindow, ZCode, Codex's catalog, Grok, omp, dsh) over what the vendor or models.dev says, and the Providers and Routing views keep it when saved. An empty value clears it 2026-09-26 14:39:55 +08:00