Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
routing: a member too small for the request keeps its row and says why (#3749)
yetone6afbe3f30474
diff --git a/docs/subsystems/gateway-routing.md b/docs/subsystems/gateway-routing.mdindex dbd4f692f..aeb11763b 100644--- a/docs/subsystems/gateway-routing.md+++ b/docs/subsystems/gateway-routing.md@@ -175,7 +175,7 @@ recorded as a prediction failure (`noPrediction`).- A resting candidate is tried last (`restLast`). Of the resting candidates, a request asks only the one whose rest ends soonest, the first in order on a tie (`probeOne`, #1799). The others aren't asked by that request, so a member that is down isn't asked by every request its rest was meant to spare it from, and a group that is down whole takes one upstream request per request, not one per member. Every ready candidate is still asked in its order. A lone candidate is tried even while it rests, because there is no other. The trace still lists every member, the resting ones with their rest. Only rests are read, and a failure about the request's content or its model rests no member (a model refusal rests only `restID`), so neither leaves a member out. The same applies in `count_tokens`, embeddings and rerank, image accounts and a group's System One decision models. A Codex reset (`autoReset`) still looks over every candidate. This is like AxonHub's error-aware load balancing: the rest and its backoff are the penalty that decays, and the member back soonest is the one asked to show it is back. Keys out of their allowance aren't asked even so, not even the one back soonest or a lone one (#1772: four Ollama Cloud keys out for the week, each asked again and refused on every request). The refusal given again says when they are asked again on this magpie's clock with its offset (`heldClock`: "20:12 UTC+8", "Oct 16 09:00 UTC+8"), as do the gateway's other held errors (a capped window, a spent searcher or describer): its reader may be a Remote magpie's user on another clock. When every candidate left is a key (not a subscription account, whose resets `autoReset` may spend) resting out of quota or credit after a 429 or 402, none is asked. The first one's refusal is given again (`quotaHeld`, its words kept in the rest's `said`), saying when it is asked again. A key whose rest magpie guessed the length of, the vendor and the user naming no time (`creditRest`, or `quotaRest` with no `Provider.OwnQuotaRest`), is held so only once it was refused so twice in a row (`Rest.first`): a single refusal may be a moment's, and the next request, the agent's retry first, asks it again (zoecats on Discord: a local aggregator said 429 `insufficient_quota` "quota exhausted" for the moment it switched upstreams, and every request was answered from its rest of 15 or 30 minutes, which only the provider's "Rests" switch, `LimitRestOff`, let through before). Held, it is asked again a minute on (`Rest.askAt`, `fallbackCooldown`), once, and held again if refused (`Rest.asksAt`); a time the vendor named, or the user set, holds it from the first refusal to then. The rest itself stays as long as before, so the order still passes it over for a candidate that is ready. The last key left rests too when it is refused so, as the keys before it do. Any 429 that reaches the agent without a vendor `Retry-After`, while every candidate tried is resting, carries one: the seconds until the first of them is asked again (`soonestBack`, by `asksAt`), none after a key's first refusal. `TestRetryAfterALimitIsAsked`, `TestHeldLimitAskedAgainInAMinute`. A quota refusal with no word of when it is back rests `quotaRest` (15 minutes), or the provider's own `quotaRest` in minutes (`Provider.QuotaRestFor`, at most `MaxQuotaRest`, 8 days; `magpie provider quota-rest <id> 7d`), or until the time of day the user said its allowance comes back (`QuotaResetAt`, `Provider.OwnQuotaRest`; `magpie provider quota-rest <id> until 08:00`, or `until 00:00+08:00` on the vendor's clock; #2008, a free tier's "today's free-model token quota"). Whichever of the two was set last counts. A time the vendor names stands over it, and so does its `Retry-After`, unless that was more than `longestWait` (an hour) and so cut to it while the user's own rest is longer: then the user's stands (`TestQuotaRestsUntilTheTimeOfDaySet`). A key listed in `keys` as well as in `key` is one candidate (`KeysOn`), not asked twice. `TestAllRestingAnswersFromRest`, `TestOwnQuotaRest`, `TestQuotaHeldOnlyForKeysOutOfAllowance`, `TestFirstKeyListedTwiceAskedOnce`.- A provider whose keys are on different plans (`KeyAccount.Plan`, `PlansMixed`; yckonnnn on X) sends each key to its plan's endpoints: every key path takes its copy through `WithKey`, which moves it there (`atKeyPlan`), on the first try and on a failover alike. `perKeyBarred` leaves out a key whose plan's list lacks the model (`PlanServing`: a pay-as-you-go model id at the Agent Plan's endpoint only answers 404), not shown in the trace; only when no key's plan has it are those keys asked. Embeddings and drawing go through the same `perKeyBarred` and `WithKey`; a video started on a mixed provider names its key in the task id (`videoStart.onKey`, `keyMark`) so its poll goes to that key's plan. `TestKeyPlansEachToItsOwnEndpoint`.- A subscription's account whose own model list lacks the model (`Account.Lists`: an Antigravity account's `fetchAvailableModels`, a plugin account's `models`) isn't planned while another of its accounts lists it (`perKeyBarred`'s `left`, `planned.unlisted`, the Routing page's "unlisted, skipped"). It is the next asked when every account of the subscription that lists the model has been asked and one refused it as a model it doesn't serve (`unservedTry`: `modelRefused`, or Code Assist's 404 NOT_FOUND, `codeAssistModelMissing`), before any later member or fallback (`unlistedNext`, `askUnlisted` moves its row from the route's left to its order after the one that refused). A list is fetched once and can be stale: 01huadalang's Gemini 4 was served by one Antigravity account of several, and the one whose list named it refused it with a 404 the agent got while the other could answer. The one that refused rests for that model alone. Not for another refusal (a 403, a quota), a request pinned to an account, a native compaction sealed to one, or a conversation kept strictly on one; a gateway key held to some accounts narrows the unlisted ones too (`allowedCandidates`). `TestUnlistedAccountAskedAfterModelRefused`, `TestUnlistedAccountNotAskedForOtherRefusals`.-- A member whose model is known to take less than the request isn't asked it (`roomy` in [`fallback.go`](../../internal/gateway/fallback.go), in `serve` after the rules, affinity, the image filter and `pinTo`, before `probeOne`; dgqyushen on Discord: OpenCode Zen's free DeepSeek V4.1 Flash, 200K, first in a group and a 1M subscription of it second). It is a check before sending, not a retry: the request's tokens are estimated as the overflow fall-over does (`estimate`, bytes/4 over text, tool arguments and schemas), and a candidate whose window (`windowOf`: the provider's `Contexts`, the catalog, `ContextOf`) is known and no larger is left out of the candidates and of the trace's order. Asked, such a member only refuses, and a refusal that doesn't say why, for a request short of `tooLongUnsaid`'s 1.2 margin, reached the agent as the vendor's error while the next member had room; it also spent a request against the member's limits. A conversation kept on a member by affinity moves once it outgrows it. Nothing is left out when its window isn't known, when the body doesn't parse, when only one model is among the candidates, or when no candidate holds the request: then the first is asked, and its overflow reaches the agent as one, to compact (`withRoom`, `failOverflow` and `tooLongUnsaid` stay for the window the estimate misses, which counts low on code and high on CJK text). A body shorter than four bytes per token of the least window isn't parsed. `count_tokens` (a count on the group's first member, not a send) and System One's decision models (short decision text) don't go through it. Those left out are the last resort: when the last candidate with room fails out of its allowance or credit (`failQuota`/`failCredit`), nothing before it having failed otherwise (`other`), and no account is pinned, the ones left out that aren't resting are asked after all, their rows added to the trace's order, and the one that failed rests as one before the last does. Its overflow tells the agent to compact, where the 429 only told it to wait for an allowance hours away (Kai on Discord: both Claude accounts spent until the next day, the Claude provider's Fallback a Codex model of 272K under a longer conversation, never asked). Another failure (a busy vendor, a bad key) still reaches the agent as it was, the small one not asked. The Routing page shows a member left out and not asked only by its absence from the route's order. `TestMemberTooSmallIsNotAsked`, `TestMemberTooSmallIsTheLastResort`, `TestClaudeAccountsSpentFallBackToCodex`, `TestConversationOutgrowingItsMemberMoves`, `TestRoomyLeavesWhatItCantJudge`.+- A member whose model is known to take less than the request isn't asked it (`roomy` in [`fallback.go`](../../internal/gateway/fallback.go), in `serve` after the rules, affinity, the image filter and `pinTo`, before `probeOne`; dgqyushen on Discord: OpenCode Zen's free DeepSeek V4.1 Flash, 200K, first in a group and a 1M subscription of it second). It is a check before sending, not a retry: the request's tokens are estimated as the overflow fall-over does (`estimate`, bytes/4 over text, tool arguments and schemas), and a candidate whose window (`windowOf`: the provider's `Contexts`, the catalog, `ContextOf`) is known and no larger is left out of the candidates and of the trace's order, and listed in the trace's `left` with `window` set to that window. Asked, such a member only refuses, and a refusal that doesn't say why, for a request short of `tooLongUnsaid`'s 1.2 margin, reached the agent as the vendor's error while the next member had room; it also spent a request against the member's limits. A conversation kept on a member by affinity moves once it outgrows it. Nothing is left out when its window isn't known, when the body doesn't parse, when only one model is among the candidates, or when no candidate holds the request: then the first is asked, and its overflow reaches the agent as one, to compact (`withRoom`, `failOverflow` and `tooLongUnsaid` stay for the window the estimate misses, which counts low on code and high on CJK text). A body shorter than four bytes per token of the least window isn't parsed. `count_tokens` (a count on the group's first member, not a send) and System One's decision models (short decision text) don't go through it. Those left out are the last resort: when the last candidate with room fails out of its allowance or credit (`failQuota`/`failCredit`), nothing before it having failed otherwise (`other`), and no account is pinned, the ones left out that aren't resting are asked after all, their rows moved from the trace's `left` to its order, and the one that failed rests as one before the last does. Its overflow tells the agent to compact, where the 429 only told it to wait for an allowance hours away (Kai on Discord: both Claude accounts spent until the next day, the Claude provider's Fallback a Codex model of 272K under a longer conversation, never asked). Another failure (a busy vendor, a bad key) still reaches the agent as it was, the small one not asked. The Routing page keeps a row for a member left out and not asked, saying the request is longer than its window and that it was passed over, and its why list says so (#3749; it used to show it only by its absence from the order). `TestMemberTooSmallIsNotAsked`, `TestMemberTooSmallIsTheLastResort`, `TestClaudeAccountsSpentFallBackToCodex`, `TestConversationOutgrowingItsMemberMoves`, `TestRoomyLeavesWhatItCantJudge`.- Routing decides who goes first only when nobody has answered the conversation yet. Affinity keeps the answerer while its cache is worth it. Auto mode keeps it across turns while the last reply read from the cache and wrote to it at least `cacheWorth` (1024) tokens between them (the usage's `CacheRead` plus `CacheWrite`, passed to `answered`) and the cache isn't cold (`cacheCold`, 5 minutes). Past 5 minutes it stays while the vendor said it keeps at least `cacheWorth` tokens of the conversation for an hour (`hourCache`, #2302): a reply with Anthropic's 1-hour writes (`cache_creation.ephemeral_1h_input_tokens`, the usage's `CacheWrite1h`, as Claude Code asks of a subscription) keeps what it read plus those for `cacheHour`, a later reply on the same account and model that reads all of it starts the hour again, and one that reads less (moved, compacted) drops it. The stick keeps it on disk too (`cacheHour`, `cacheHourAt`), and a group's rules keep the turn's effort the same hour (`keepsEffort`). Vendors that report no 1-hour write are unchanged. `TestAffinityKeepsAnHourCachePastFiveMinutes`, `TestHourCacheAfter`. What was written counts: a first turn reads nothing and writes the whole prompt (Anthropic's `cache_creation_input_tokens`), and the second turn stays to read it rather than moving as `no-cache` and building it again elsewhere (vilicvane on Discord). The stick keeps both, on disk too (`affinity.json`'s `cacheWrite`, absent in a file from before and read as 0, so such a stick is judged by its read alone), and the trace's `Affinity.CacheWrite` lets the Routing page say what was read and what was written. A vendor that keeps a prompt cached without reporting it (OpenAI's automatic prefix cache, Gemini) says neither of a turn that read none, so the prompt that turn was sent (the usage's `Input`) stands for the write and its second turn stays too; a reply that reports no usage at all counts as no cache, as before. `TestAffinityKeepsACacheJustWritten`, `TestAffinityKeepsACacheTheVendorKeptSilently`, `routing-affinity-cache-write.test.cjs`.- Strict (`strict`, #1797, miniers) never moves a conversation to another key or account (`who`). Its stick is kept as session's is, and while it is fresh `affine` keeps only the candidates of that `who` (`strictOnly`): its other models stay, so a group's rules still pick among them, but no other account, key or provider is asked, and a resting or spent one is asked anyway. A failure there reaches the agent and rests the account as a non-lone candidate's would (`strictAlone`), so new conversations go elsewhere. A reply that breaks off after its 200 (#733) forgets the stick under every other mode; under strict it doesn't, so the agent's retry goes back to the same account, member or key, failing there while it fails and going on there once it answers (imwhatiam123 on Discord: a group of Qoder CN and WorkBuddy AI moved a session to WorkBuddy AI, the retry routed as a new conversation; `TestStrictGroupKeepsItsMemberPastABrokenReply`). Before planning, `strictKeep` takes the stuck account back from what holds new conversations off it: a usage cap (`pl.capped`, `capHeldOnly`), so the conversation goes on past it. An account held for credits it may not spend is answered 429 naming the account and Strict, and nothing reaches the vendor, rather than moved. An account removed, switched off, barred, or not allowed for the calling key is gone, and the conversation moves as under session. The trace says `strict` even with one candidate. `strict_affinity_test.go`, `stays-strict.test.cjs`.- In turn (`rotate`), a conversation nobody has answered yet goes to the key, account or model the fewest other conversations of the provider's model or the group answered in the last `heldFor` (30 minutes) are on (`leastHeld`, #946). Ties, resting ones and a group with a group in it keep routing's order. With session affinity, two sessions of one group so stay on different models.diff --git a/internal/gateway/fallback.go b/internal/gateway/fallback.goindex fa4a64429..6ae086e33 100644--- a/internal/gateway/fallback.go+++ b/internal/gateway/fallback.go@@ -1523,7 +1523,9 @@ func holds(c candidate, tokens int) bool {// to compact.//// Those left out are handed back (small, their rows in smallW when the-// order has one each), kept for the last resort: when every candidate+// order has one each, with Window set to the window: the trace lists+// them as left out, so the Routing page keeps their rows and says why,+// #3749), kept for the last resort: when every candidate// with room is out of its allowance, a fallback too small is asked all// the same (Kai on Discord: both Claude accounts at their limit until// the next day, the Claude provider's Fallback a Codex model of 272K@@ -1563,7 +1565,9 @@ func roomy(cs []candidate, pl planned, from provider.Protocol, body []byte) (outif w := windows[key(c)]; w > 0 && tokens >= w {small = append(small, c)if parallel {- smallW = append(smallW, pl.order[i])+ x := pl.order[i]+ x.Window = w+ smallW = append(smallW, x)}continue}diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.goindex 5ac0c27c6..c39371db7 100644--- a/internal/gateway/gateway.go+++ b/internal/gateway/gateway.go@@ -2381,7 +2381,7 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request, from provider.Procapture.tools = tools}tierAsked := bodyTier(from, body) // the service tier the client asked for (#1784)- tr := s.trace.beginFor(r, Route{turn: turn, dirOf: dirOf(from, plain), tools: tools, imageTurn: drawingTurnID(metadata.Turn), imageCaller: codexTurnKey(r, call.Agent), TitleLink: link, Pinned: pin, Time: start, Agent: call.Agent, Session: sessionOf(r.Header), Conv: convOf(r.Header, body), ParentSession: titleParentSession(r.Header, metadata, call.Kind), Kind: call.Kind, For: call.For, Model: call.Model, Effort: requestEffort(from, body), Tier: tierAsked, Provider: p.ID, Group: group, Rule: hit, Nested: nested, SealedTask: sealedTask, LeadAccount: leadAccount, Compaction: compactionWho(checkpoint), Subagent: subagent, SubagentEffort: subagentEffort, Sub: subOf(r.Header), SubagentID: subagentID, Affinity: shown, Order: pl.order, Left: pl.left})+ tr := s.trace.beginFor(r, Route{turn: turn, dirOf: dirOf(from, plain), tools: tools, imageTurn: drawingTurnID(metadata.Turn), imageCaller: codexTurnKey(r, call.Agent), TitleLink: link, Pinned: pin, Time: start, Agent: call.Agent, Session: sessionOf(r.Header), Conv: convOf(r.Header, body), ParentSession: titleParentSession(r.Header, metadata, call.Kind), Kind: call.Kind, For: call.For, Model: call.Model, Effort: requestEffort(from, body), Tier: tierAsked, Provider: p.ID, Group: group, Rule: hit, Nested: nested, SealedTask: sealedTask, LeadAccount: leadAccount, Compaction: compactionWho(checkpoint), Subagent: subagent, SubagentEffort: subagentEffort, Sub: subOf(r.Header), SubagentID: subagentID, Affinity: shown, Order: pl.order, Left: append(slices.Clip(pl.left), smallW...)})if watched != nil {watched.routeID = tr.ID}@@ -3597,7 +3597,9 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request, from provider.Pro}next = append(next, x)if len(smallW) == len(small) {- nextW = append(nextW, smallW[k])+ w := smallW[k]+ w.Window = 0 // asked after all: weighed, not left out+ nextW = append(nextW, w)}}small = nil@@ -3607,6 +3609,9 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request, from provider.Pros.trace.update(tr, func(t *Route) {t.Tries[len(t.Tries)-1] = tryt.Order = append(slices.Clip(t.Order), nextW...)+ t.Left = slices.DeleteFunc(slices.Clone(t.Left), func(l Weighed) bool {+ return l.Window > 0 && slices.ContainsFunc(nextW, func(w Weighed) bool { return w.ID == l.ID && w.Model == l.Model })+ })})skipped = append(skipped, c.label()+": "+call.Error)cands = append(cands[:len(cands):len(cands)], next...)diff --git a/internal/gateway/roomy_test.go b/internal/gateway/roomy_test.goindex 6c0108d77..b843beb0f 100644--- a/internal/gateway/roomy_test.go+++ b/internal/gateway/roomy_test.go@@ -56,6 +56,11 @@ func TestMemberTooSmallIsNotAsked(t *testing.T) {if slices.ContainsFunc(r.Order, func(w Weighed) bool { return w.Provider == "free" }) {t.Fatalf("the free member is still in the order: %+v", r.Order)}+ // but the trace keeps it as left out, with the window it lacked, so+ // the Routing page keeps its row and says why (#3749)+ if i := slices.IndexFunc(r.Left, func(w Weighed) bool { return w.Provider == "free" }); i < 0 || r.Left[i].Window != 2000 {+ t.Fatalf("the free member isn't left out with its window: %+v", r.Left)+ }// a request it holds goes to it, firstfree.replies = []reply{{200, "", chatOK}}@@ -98,9 +103,13 @@ func TestMemberTooSmallIsTheLastResort(t *testing.T) {if len(r.Tries) != 2 || r.Tries[0].ID != "paid" || r.Tries[0].Rest == nil || r.Tries[1].ID != "free" {t.Fatalf("tries %+v", r.Tries)}- if !slices.ContainsFunc(r.Order, func(w Weighed) bool { return w.Provider == "free" }) {+ if !slices.ContainsFunc(r.Order, func(w Weighed) bool { return w.Provider == "free" && w.Window == 0 }) {t.Fatalf("the free member asked isn't in the order: %+v", r.Order)}+ // asked after all, it is no longer told as left out (#3749)+ if slices.ContainsFunc(r.Left, func(w Weighed) bool { return w.Provider == "free" }) {+ t.Fatalf("the free member asked is still left out: %+v", r.Left)+ }}// A conversation that began on the free member, and is kept there bydiff --git a/internal/gateway/trace.go b/internal/gateway/trace.goindex e97545899..f0039b5fe 100644--- a/internal/gateway/trace.go+++ b/internal/gateway/trace.go@@ -268,6 +268,10 @@ type Weighed struct {Speaks provider.Protocol `json:"speaks,omitempty"` // a key made for one protocol onlyRest *Rest `json:"rest,omitempty"` // resting after a failure, when the request cameUnlisted bool `json:"unlisted,omitempty"`+ // Window: left out as the request is longer than this, its model's+ // context window (roomy), unless every one with room is out of its+ // allowance (#3749)+ Window int `json:"window,omitempty"`// DueBy: "reset" when Due is when an auto-used Codex reset about to// run out starts the windows again, sooner than they renew (#717)DueBy string `json:"dueBy,omitempty"`diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.jsindex b82996d23..195813858 100644--- a/internal/gui/assets/plugins/routing/client.js+++ b/internal/gui/assets/plugins/routing/client.js@@ -818,6 +818,8 @@ function routingPage(part) {for (const x of r.order.filter((x) => x.aside)) out.push(t("{who} is made for {api}, not {other} as the keys routed over are, so it isn't one of them: it's tried after them.", { who: who(x), api: API[x.speaks] || x.speaks || t("any API"), other: API[pooled?.speaks] || pooled?.speaks || t("any API") }));for (const x of r.left || []) out.push(x.held? t("{who} is left out: the gateway key asking may not use its account.", { who: who(x) })+ : x.window+ ? t("{who} is left out: this request is longer than its {n} context window, so it would only refuse it. It's asked only once every one with room is out of its allowance.", { who: who(x), n: ctxShort(x.window) }): x.noCredits? t("{who} is left out: a usage window is used up, and the account is set not to spend its credits, so it counts as used up until that window renews.", { who: who(x) }): x.capped@@ -1802,7 +1804,9 @@ function routingPage(part) {// comes back when its window renews, and a group member held so would// otherwise vanish from the stage (#2129, wyq0x55: d-task's gpt-sol-6.1,// used up, wasn't shown while a used-up Claude was).- const heldOut = (w) => !w.held && !!(w.capped || w.noCredits);+ // window: passed over as the request is longer than its model's+ // context window (#3749), a row of its own as one at a cap is+ const heldOut = (w) => !w.held && !!(w.capped || w.noCredits || w.window);function seated(r) {const members = r.group?.members || [];const key = (w) => {@@ -2309,6 +2313,7 @@ function routingPage(part) {let s;if (w.unlisted) s = unlistedWord(w);else if (resting) s = `${failWord(rest.why)} · ${restWhen(rest)}`;+ else if (w.window) s = t("request longer than its {n} window · passed over", { n: ctxShort(w.window) });// a row another request weighed, answering that one: the header// tells of this request, so it says the answer is not this one'selse if (trying.has(id)) s = r.id !== cur.id && agents.size <= 1 ? t("answering another request…") : t("answering…");@@ -2352,9 +2357,9 @@ function routingPage(part) {lightRow(row.li, row.wire, on, flying);row.li.classList.toggle("low", !!(!w.routing && w.known && w.used >= 90));row.li.classList.toggle("rest", !!resting || gave.has(id));- row.li.classList.toggle("left", !!w.unlisted);+ row.li.classList.toggle("left", !!w.unlisted || !!w.window);if (on) row.wire.style.setProperty("--agent", hueOf(r.agent));- row.wire.classList.toggle("rest", !!resting || !!w.unlisted);+ row.wire.classList.toggle("rest", !!resting || !!w.unlisted || !!w.window);}// a fold tells of its keys together: the one answering or that// answered, by name, then how many are there to route to and how manydiff --git a/internal/gui/assets/plugins/routing/i18n.js b/internal/gui/assets/plugins/routing/i18n.jsindex 1a0df37ef..e28470d82 100644--- a/internal/gui/assets/plugins/routing/i18n.js+++ b/internal/gui/assets/plugins/routing/i18n.js@@ -506,6 +506,8 @@ magpie.strings({"set to serve other models, not {model}": "已设为只用于其他模型,不含 {model}","{who} is left out: it is set to serve other models, not {model}.": "{who} 不参与:它已设为只用于其他模型,不含 {model}。","held at its {cap}% usage cap": "已达 {cap}% 用量上限",+ "request longer than its {n} window · passed over": "请求超出其 {n} 上下文 · 已跳过",+ "{who} is left out: this request is longer than its {n} context window, so it would only refuse it. It's asked only once every one with room is out of its allowance.": "{who} 不参与:这个请求超出它 {n} 的上下文窗口,发给它只会被拒绝。只有能容下的都用完额度时才会问它。","not an account the gateway key may use": "不是该网关密钥可用的账号","{who} is left out: the gateway key asking may not use its account.": "{who} 被排除:发起请求的网关密钥不能使用它的账号。","{who} is left out: a usage window is used up, and the account is set not to spend its credits, so it counts as used up until that window renews.": "{who} 不参与:某个用量窗口已用完,且该账号设为不使用积分,窗口重置前视为已用完。",@@ -1069,6 +1071,8 @@ magpie.strings({"set to serve other models, not {model}": "已設為只用於其他模型,不含 {model}","{who} is left out: it is set to serve other models, not {model}.": "{who} 不參與:它已設為只用於其他模型,不含 {model}。","held at its {cap}% usage cap": "已達 {cap}% 用量上限",+ "request longer than its {n} window · passed over": "請求超出其 {n} 上下文 · 已略過",+ "{who} is left out: this request is longer than its {n} context window, so it would only refuse it. It's asked only once every one with room is out of its allowance.": "{who} 不參與:這個請求超出它 {n} 的上下文視窗,送給它只會被拒絕。只有容得下的都用完額度時才會問它。","not an account the gateway key may use": "不是該閘道金鑰可用的帳號","{who} is left out: the gateway key asking may not use its account.": "{who} 被排除:發起請求的閘道金鑰不能使用它的帳號。","{who} is left out: a usage window is used up, and the account is set not to spend its credits, so it counts as used up until that window renews.": "{who} 不參與:某個用量時段已用完,且該帳號設為不使用積分,時段重置前視為已用完。",@@ -1630,6 +1634,8 @@ magpie.strings({"set to serve other models, not {model}": "{model} ではなく他のモデル用に設定","{who} is left out: it is set to serve other models, not {model}.": "{who} は除外:{model} ではなく他のモデル用に設定されています。","held at its {cap}% usage cap": "使用量上限 {cap}% で停止中",+ "request longer than its {n} window · passed over": "リクエストが {n} のコンテキストを超過 · スキップ",+ "{who} is left out: this request is longer than its {n} context window, so it would only refuse it. It's asked only once every one with room is out of its allowance.": "{who} は除外:このリクエストは {n} のコンテキストウィンドウを超えており、送っても拒否されるだけです。余裕のあるものがすべて枠を使い切ったときだけ使われます。","not an account the gateway key may use": "ゲートウェイキーが使えるアカウントではありません","{who} is left out: the gateway key asking may not use its account.": "{who} は外されています:リクエストしたゲートウェイキーはそのアカウントを使えません。","{who} is left out: a usage window is used up, and the account is set not to spend its credits, so it counts as used up until that window renews.": "{who} は除外:使用量ウィンドウの 1 つを使い切り、アカウントはクレジットを使用しない設定のため、そのウィンドウが更新されるまで使い切ったものとみなします。",@@ -2193,6 +2199,8 @@ magpie.strings({"set to serve other models, not {model}": "nur für andere Modelle eingestellt, nicht für {model}","{who} is left out: it is set to serve other models, not {model}.": "{who} wird übergangen: nur für andere Modelle eingestellt, nicht für {model}.","held at its {cap}% usage cap": "am Nutzungslimit von {cap} % angehalten",+ "request longer than its {n} window · passed over": "Anfrage länger als sein {n}-Fenster · übergangen",+ "{who} is left out: this request is longer than its {n} context window, so it would only refuse it. It's asked only once every one with room is out of its allowance.": "{who} wird übergangen: Diese Anfrage ist länger als sein Kontextfenster von {n}, es würde sie nur ablehnen. Es wird erst gefragt, wenn alle mit genug Platz ihr Kontingent aufgebraucht haben.","not an account the gateway key may use": "kein Konto, das dieser Zugangsschlüssel nutzen darf","{who} is left out: the gateway key asking may not use its account.": "{who} wird übergangen: der fragende Zugangsschlüssel darf sein Konto nicht nutzen.","{who} is left out: a usage window is used up, and the account is set not to spend its credits, so it counts as used up until that window renews.": "{who} wird übergangen: Ein Zeitfenster ist aufgebraucht, und das Konto soll keine Credits verbrauchen, daher gilt es bis zur Erneuerung des Zeitfensters als aufgebraucht.",diff --git a/internal/gui/tests/routing-small-seat.test.cjs b/internal/gui/tests/routing-small-seat.test.cjsnew file mode 100644index 000000000..95627cbd4--- /dev/null+++ b/internal/gui/tests/routing-small-seat.test.cjs@@ -0,0 +1,92 @@+// Run with Node's test runner and Playwright on the module path; see README.md.+// #3749 (MYCF711): a member whose model's context window the request is+// longer than isn't asked (roomy), and its row used to go from the Routing+// page with no word of why. The trace now lists it in the route's left,+// with window set to the window it lacked: its row stays, says the request+// is past its window and that it was passed over, faded as a seat held out+// is, and the why list says so rather than "its plan doesn't list". In+// every language, at a window's width and at 420px, in both engines.+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 now = Date.now();+const iso = (ms) => new Date(ms).toISOString();+const big = { id: "sub@[email protected]", provider: "sub", name: "Sub", who: "[email protected]", kind: "account", model: "deepseek-v4-flash", routing: "", known: true, used: 20 };+const small = { id: "zen", provider: "zen", name: "OpenCode Zen", kind: "provider", model: "deepseek-v4-flash-free", routing: "", window: 200000 };+const group = { id: "flash", name: "Flash", routing: "order", members: ["zen/deepseek-v4-flash-free", "sub/deepseek-v4-flash"] };+const route = {+ id: 7, seq: 7, time: iso(now - 2000), agent: "claude", model: "group/flash", provider: "sub", group, done: true, status: 200, ms: 900, tokens: 250000,+ order: [big], left: [small], tries: [{ id: big.id, model: big.model, start: iso(now - 2000), done: true, ms: 800, status: 200 }],+};++function serve(lang) {+ const state = { agents: [{ id: "claude", name: "Claude Code", path: "/test/claude", fields: [] }], profiles: [], settings: { lang, theme: "light" } };+ return async (r) => {+ const url = new URL(r.request().url());+ const json = (data) => r.fulfill({ json: data });+ if (url.pathname === "/boot.js") return r.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });+ if (url.pathname === "/wails/runtime.js") return r.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });+ if (url.pathname === "/api/state") return json(state);+ if (url.pathname === "/api/gateway/trace") {+ if (url.searchParams.get("wait")) return new Promise(() => {}); // nothing more comes+ return json({ mine: true, now: new Date().toISOString(), seq: 7, totals: { requests: 1, rerouted: 0, errors: 0 }, routes: [route] });+ }+ if (url.pathname === "/api/usage/quotas") return json([]);+ if (url.pathname === "/api/usage/quotas/history") return json([]);+ if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });+ if (url.pathname === "/api/groups") return json({ models: [], groups: [], pools: [] });+ if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true, url: "http://127.0.0.1:3999" } });+ 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 r.fulfill({ body: await fs.readFile(file), contentType });+ };+}++const words = {+ en: ["request longer than its 200K window · passed over", "OpenCode Zen is left out: this request is longer than its 200K context window, so it would only refuse it. It's asked only once every one with room is out of its allowance."],+ zh: ["请求超出其 200K 上下文 · 已跳过", "OpenCode Zen 不参与:这个请求超出它 200K 的上下文窗口,发给它只会被拒绝。只有能容下的都用完额度时才会问它。"],+ "zh-TW": ["請求超出其 200K 上下文 · 已略過", "OpenCode Zen 不參與:這個請求超出它 200K 的上下文視窗,送給它只會被拒絕。只有容得下的都用完額度時才會問它。"],+ ja: ["リクエストが 200K のコンテキストを超過 · スキップ", "OpenCode Zen は除外:このリクエストは 200K のコンテキストウィンドウを超えており、送っても拒否されるだけです。余裕のあるものがすべて枠を使い切ったときだけ使われます。"],+ de: ["Anfrage länger als sein 200K-Fenster · übergangen", "OpenCode Zen wird übergangen: Diese Anfrage ist länger als sein Kontextfenster von 200K, es würde sie nur ablehnen. Es wird erst gefragt, wenn alle mit genug Platz ihr Kontingent aufgebraucht haben."],+};++for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {+ test(`${engine}: a member the request is too long for keeps its row and says why`, async (t) => {+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));+ t.after(() => browser.close());+ for (const lang of Object.keys(words)) {+ for (const width of [1100, 420]) {+ await t.test(`${lang} at ${width}px`, async () => {+ const ctx = await browser.newContext({ viewport: { width, height: 760 }, reducedMotion: "reduce" });+ try {+ const page = await ctx.newPage();+ page.setDefaultTimeout(5000);+ const errors = [];+ page.on("pageerror", (e) => errors.push(e.message));+ await page.route("**/*", serve(lang));+ await page.goto("http://magpie.test/?view=routing");+ const row = page.locator(`.rt-accts > li[title^="${small.id}"]`).first();+ await row.locator("em").filter({ hasText: /\S/ }).waitFor();+ const [rowWord, why] = words[lang];+ assert.equal(await row.locator("em").textContent(), rowWord);+ assert.ok(await row.evaluate((li) => li.classList.contains("left")), "faded as a seat held out is");+ // the one that answered is still drawn as it was+ await page.locator(`.rt-accts > li[title^="${big.id}"]`).first().waitFor();+ // the why list names it and its window, not its plan+ assert.ok((await page.locator("body").textContent()).includes(why), "the why list says why");+ const over = await page.evaluate(() => document.documentElement.scrollWidth - innerWidth);+ assert.ok(over <= 1, `${lang} at ${width}: ${over}px past`);+ assert.deepEqual(errors, []);+ } finally {+ await ctx.close();+ }+ });+ }+ }+ });+}