routing: a provider's accounts routed In order give a conversation back to the first

CryptoSarom on X: with a provider's accounts set to In order, a
conversation that had moved to the second account (the first was
resting) stayed on the second once the first was ready again. Only a
group's members went back to the first; a provider's own accounts never
did, because inOrder was read from the group's routing alone.

- gateway.go: inOrder comes from the provider's routing, or the group's
  when the request is to a group.
- affinity.go: backToFirst compares accounts (who()) for a provider's
  own accounts. For a provider it overrides only a cache that would have
  kept the conversation (cacheHolds: worth keeping and still warm), so a
  cold or empty cache keeps its own "cold"/"new" label.
- plugin_factory_cap_test.go: "auto, cached on B" pinned the old
  stay-on-B behaviour; it now expects A, the first account, on purpose.
- GUI: the Routing affinity line for "order" without a group says the
  provider goes in order and the first is ready again (all languages).
- docs/subsystems/gateway-routing.md: the In order bullet covers a
  provider's own accounts.

Run on mote at this tree on aa3d11d5b; rebased onto c6702f462, which changes only context.css and its own GUI test: gofmt -l clean,
GOOS=linux and GOOS=windows go vet ./internal/gateway ok, go test
./internal/gateway -count=1 -timeout 45m ok (985s).
GUI: routing-affinity-order (new accounts case) and i18n ok in both
engines. i18n-keys "a plugin's words are its own" is red from three
strings not in this change, filed as #5332, #5426, #5482.

Broken by hand: inOrder := false turns
TestOrderedAccountsGiveTheConversationToTheFirst red (k1 k1 k1 k1, why
"cache"). Without cacheHolds TestForeignSealedItemsAfterAColdSwitch went
red (why "order" for a cold switch).

Not tried: a real account pair in the live app.
This commit is contained in:
yetone
2026-11-09 05:42:44 +08:00
parent c6702f4626
commit 82ca554be9
8 changed files with 130 additions and 17 deletions
+1 -1
View File
@@ -242,7 +242,7 @@ recorded as a prediction failure (`noPrediction`).
- A conversation kept where it is (`Affinity.Kept`: Auto with a warm cache, Session, or within a turn) whose key or account fails before anything is sent, in a way that passes (`busy`: an overloaded 503 or 529, another 5xx that says nothing of quota, a 408), and not as a rate limit (429), a quota, a refusal or a sign-in, is asked once more after `retryPause` (1s, or a Retry-After up to `longestPause`) without resting, before the request moves on (`keptAgain` in [`affinity.go`](../../internal/gateway/affinity.go), jiabubu on Discord: a channel that errs once and is back a moment later had the conversation moved off it at once, to be sent it all uncached elsewhere). Once a request; failing again, it rests and the next is asked as before. A conversation nobody has answered yet, or under Off, moves at once, as it has no cache to keep; Strict's lone candidate is the last one left, asked again as that is (`lastRetries`). The trace marks the try (`Try.Kept` with its `Again`), and the Routing page says it was asked again for what its vendor cached, not that nobody else was left. `TestKeptConversationAskedAgainBeforeItMoves`, `routing-kept-again.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`.
- A provider's fallback is its emergency path, not a place a conversation stays (01huadalang on Discord). When the one that answered a conversation last is one of a provider's `Fallback` models (its trace row's `Fallback`) and the provider's own model stands first in the plan, ready, the next turn goes to the provider, whatever the fallback cached and in every mode but Strict (`backToMain` in `affine`, `Affinity.Why` `main`). "Ready" is what `restLast` says: the provider's rest over, which is when the rest `restAfter` set ends (a minute and backing off for a plain failure, the vendor's named reset or Retry-After for a quota or rate limit, `quotaRest` 15 minutes when nothing names a time), or earlier when its windows are read full no more (`renewed`) or a background probe finds it answering (`Rest.Probed`). While the provider rests, the fallback is ahead of it and keeps the conversation as any answerer does. Within a turn (the agent sending tool results back) the conversation stays on the fallback until the user speaks again: the turn's tool loop runs on reasoning the fallback sealed, which the provider can't read, and the provider is sent the whole prompt afresh at the next turn all the same. Strict is left as the user set it: it never moves a conversation, a fallback's included; the trace then names the provider's ready key or account (`Affinity.Main`) and the Routing page says the conversation stays on the fallback for Strict while new conversations go to the provider (`TestStrictKeepsTheFallbackAndSaysTheMainIsReady`, `routing-affinity-order.test.cjs`). A provider routed In turn goes round its own keys and accounts only: its next turn (`after`) and a new conversation (`leastHeld`) pass over a fallback while one of the provider's own leads (`standsIn`). Before, a fallback was one more seat in the round, so with one key every other turn went to the fallback, and a new conversation went to it as the one nobody was on, the provider ready (01huadalang again, 10-31; `TestRotatingProviderKeepsItsFallbackForEmergencies`, `TestFallbackGivesBackAcrossRoutings`). A routing group's members are never `Fallback`; a group gives a conversation back by its own rules (`order`, `back`, below), and a routing group named as a provider's fallback is a fallback here as a whole. Before this, Auto kept a conversation on the fallback by its cache for as long as each turn read it, and Session for the session. `TestFallbackGivesTheConversationBackOnceTheMainIsReady`. The Routing page says so ("{who}, a fallback, answered this conversation last, but the provider's own {first} is ready again…", `affWhy` in `plugins/routing/client.js`); before, `main` showed no reason at all.
- A routing group set to In order is tried in the order the user put its members in, and a later member keeps a conversation only until a member ahead of it is ready again (yyhhyyyyyy on Discord: an API key first and a Claude subscription second for Opus, 8 of 10 Claude Code requests on the subscription). One failure of the first member (a 429, a 5xx, a rest) sent a conversation to the second, and Auto affinity's `cache` kept it there at every turn after, since each turn read what the last had written. Now, with Stays left on Auto, a new turn goes back to the first ready member when it is another member than the one that answered last (`backToFirst` in `affine`, `Affinity.Why` `order`; another key or account of the same member, or a group in the group, keeps its own affinity). Within a turn it stays, on the reasoning the later member sealed, as with `main`. Stays: Session and Strict are the user's own and keep the conversation where it is. The Routing page says why it moved. `TestOrderedGroupGivesTheConversationBackToItsFirstMember`, `routing-affinity-order.test.cjs`.
- A routing group set to In order is tried in the order the user put its members in, and a later member keeps a conversation only until a member ahead of it is ready again (yyhhyyyyyy on Discord: an API key first and a Claude subscription second for Opus, 8 of 10 Claude Code requests on the subscription). One failure of the first member (a 429, a 5xx, a rest) sent a conversation to the second, and Auto affinity's `cache` kept it there at every turn after, since each turn read what the last had written. Now, with Stays left on Auto, a new turn goes back to the first ready member when it is another member than the one that answered last (`backToFirst` in `affine`, `Affinity.Why` `order`; another key or account of the same member, or a group in the group, keeps its own affinity). A provider whose own keys or accounts are routed In order does the same among them (CryptoSarom on X: a conversation that went to the second account while the first was resting stayed there by its cache once the first was back): `affine` gets `inOrder` from the provider's routing when the request isn't to a group, and `backToFirst` then compares accounts (`candidate.who`) rather than members. `TestOrderedAccountsGiveTheConversationToTheFirst`. Within a turn it stays, on the reasoning the later member sealed, as with `main`. Stays: Session and Strict are the user's own and keep the conversation where it is. The Routing page says why it moved. `TestOrderedGroupGivesTheConversationBackToItsFirstMember`, `routing-affinity-order.test.cjs`.
- A group routed any other way (Smart, Least used first, By weight and the rest, In turn aside) gives back a conversation a later member took only as a stand-in (01huadalang on Discord, 11-01: Codex on two accounts first in a Smart group, a MiMo key second as the backup; after an outage of Codex's 5 hours, a session that had gone to MiMo stayed there by MiMo's cache once Codex was back, while new ones went to Codex). A member stood in when, as it answered, a member the group lists ahead of its own was resting (a 429, a 5xx: `restAfter` rests the one that failed before the try goes on) or known all but used up (`Used` at `SpentShareOf`): `standsInFor`, over the plan as it was for the request, by each candidate's `place` in the group's list (`placed` in `planGroup`; a group in the group is one member). The stick keeps it (`stick.stoodIn`, and `stoodIn` in `affinity.json`, absent from a file written before and read as no stand-in) while the same account and model answer on, so a stand-in that routing still puts first after the one ahead is back (Smart's low tier, a week at 92%) gives the conversation back once routing puts the one ahead first. At a new turn, with Stays on Auto, the conversation goes to the first ready member when that one is listed ahead of the stand-in's (`backFromStandIn`, `Affinity.Why` `back`); another key or account of the same member keeps it by its cache. A member routing put first while those ahead of it were ready and had room is no stand-in and keeps its cache as before, so peers of a Smart group don't trade conversations by renewal order. Within a turn it stays; Within a turn and Off route each new turn afresh anyway; Session and Strict keep it where it is; In turn's next turn goes round (`after`). Routing still decides who is first: Least used first and Smart put a key whose usage isn't told (counted unused) ahead of accounts at 90% or more of a window, so a conversation, and every new one, goes to such a backup while the subscription's accounts are that low (routing's own choice, not affinity's; In order keeps a backup last). `TestGroupBackupGivesTheConversationBack`, `TestGroupBackupStandingInWhileTheFirstIsBackAndBehind`, `TestGroupMemberPutFirstOnItsMeritsKeepsItsCache`, `TestGroupStandInStaysWithinATurn`, `TestGroupMemberGivesTheConversationBackOnceTheOneAheadIsBack`, `routing-affinity-order.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, a provider's fallback while the provider's own leads (`standsIn`) 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.
- Requests that come together spread (`burstSpread` in [`burst.go`](../../internal/gateway/burst.go), #5242: Moody-Sin and Tericerice sent four at once to three Antigravity accounts, In turn and By pace, and every one went to one account). Routing weighs what each seat served (`Tokens`) and its allowance, which move only once a reply ends, and a lane counts a request only once its try begins, so requests planned at the same moment were all planned on the same figures; In turn's next turn (`after`) reads a stick that moves only on an answer too. Once the plan is made (after affinity, rules, pinning, `roomy`, `behindOverflow`), `burstSpread` puts first, of the candidates alike to the first, the one with the fewest requests in flight (`inFlight`, by `candidate.who`), ties keeping routing's order, and counts the request there in the same hold of the lock; the count is given back when `serve` ends. Alike (`burstAlike`): ready as the first is (not resting, aside, reserved, barred, held, capped, a fallback standing in, credits-last or busy behind), the same fallback, fit, protocol, URL and `Via`, the rule's member when a group's rule picked one; In turn any of the round; By pace a pace within a tenth (`paceAlike`, routes.Pace's band), the same `Learns`, both with room (`burstTier` 0) and no wallet told apart (`sameBalance`); Least used within a point used, the same tier and known-ness. In a group, a provider routed its own way (`ownRouting`) is alike only to its own provider's keys, by its routing, and a group in the group to nothing. Smart, In order, By weight and the others keep their order. Not moved, only counted: a conversation kept (`Affinity.Kept`), Strict, an `X-Magpie-Account` pin, a sealed task's lead, a native compaction's reader, and a new conversation `leastHeld` spreads (In turn, `spreadsSessions`), which counts those in flight itself (`sticks.opening`). A plugin's provider and a remote magpie take the same path; the remote spreads over its own accounts, the sessions passed on to it (`passOnCaller`). Not done: putting a markedly slower account behind (speed is read only for Speed first, `speedOf`), as a first token's wait goes with the prompt's size and the vendor's queue more than with the account. `burst_spread_test.go`.
+22 -5
View File
@@ -539,7 +539,8 @@ func stickKey(scope string, in http.Header, body []byte) string {
// (dirOf): one parse of a held body serves both (factsOf), where counting
// it in the masked body parsed the conversation a second time, ~27 MB
// more for each 4 MB Codex request in flight. inOrder: the request is to
// a routing group set to In order, whose order the user chose (backToFirst).
// a routing group, or a provider's keys or accounts, set to In order,
// whose order the user chose (backToFirst).
func affine(scope, mode string, rotate, spread, inOrder bool, in http.Header, from provider.Protocol, body, written []byte, cs []candidate, pl planned) ([]candidate, planned, *Affinity, string) {
key := stickKey(scope, in, body)
a := &Affinity{Mode: mode}
@@ -618,7 +619,7 @@ func affine(scope, mode string, rotate, spread, inOrder bool, in http.Header, fr
// for it, which the provider can't read, and the whole prompt is
// sent afresh to the provider at the next turn all the same
a.Why = "main"
case !a.Within && inOrder && mode == "" && backToFirst(cs, pl.order, at):
case !a.Within && inOrder && mode == "" && backToFirst(cs, pl.order, at, !strings.HasPrefix(scope, provider.GroupPrefix)) && (strings.HasPrefix(scope, provider.GroupPrefix) || cacheHolds(st, cs[at].p)):
// a group set to In order tries its members in the order the user
// put them in: a conversation that went to a later member while
// the first couldn't take it (a 429, a 5xx, a rest) goes back to
@@ -629,7 +630,10 @@ func affine(scope, mode string, rotate, spread, inOrder bool, in http.Header, fr
// Discord: an API key first, a Claude subscription second, 8 of 10
// requests on the subscription). Within a turn it stays, on the
// reasoning the later member sealed; Stays: Session or Strict,
// the user's own, keep it where it is
// the user's own, keep it where it is. A provider's own keys or
// accounts routed In order do the same (CryptoSarom on X); only
// a cache that would keep it is overridden, so one gone cold or
// never written is still told as that
a.Why = "order"
case !a.Within && !inOrder && !rotate && mode == "" && st.stoodIn && backFromStandIn(cs, pl.order, at):
// a member listed after another, in a group routed Smart or any
@@ -721,12 +725,17 @@ func backToMain(order []Weighed, at int) bool {
// first, order[0], is a member of the group ahead of the member that
// answered last, cs[at]: another member, not another key or account of
// the same one (a provider's keys, a group in the group, keep their own
// affinity). restLast puts a resting one behind every ready one, so the
// affinity). accounts: a provider's own keys or accounts routed In order,
// where the first is another key or account of the provider's own, not a
// fallback. restLast puts a resting one behind every ready one, so the
// first is ready only when it isn't resting.
func backToFirst(cs []candidate, order []Weighed, at int) bool {
func backToFirst(cs []candidate, order []Weighed, at int, accounts bool) bool {
if at <= 0 || at >= len(order) || at >= len(cs) || order[0].Rest != nil || order[0].Aside {
return false
}
if accounts {
return !order[0].Fallback && !order[at].Fallback && cs[0].who() != cs[at].who()
}
member := func(i int) string {
if len(order[i].Via) > 0 {
return provider.GroupPrefix + order[i].Via[0]
@@ -1505,3 +1514,11 @@ func keptAgain(aff *Affinity, c candidate, hw *holdWriter, asked bool) (time.Dur
}
return passing(hw.code(), hw.header, hw.errBody(), 0)
}
// cacheHolds says whether what the conversation has cached would keep it
// where it is: enough written or read (cacheWorth), and not gone cold
// (coldAfter, or kept for an hour: #2302). The "no-cache" and "cold"
// cases of affine read the same.
func cacheHolds(st stick, p provider.Provider) bool {
return st.cacheRead+st.cacheWrite >= cacheWorth && (time.Since(st.at) <= coldAfter(p) || st.hour.warm(time.Now()))
}
+4 -1
View File
@@ -2979,7 +2979,10 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request, from provider.Pro
// (#63): its reasoning, sealed by the account that wrote it, is refused
// by another.
before := len(cands)
inOrder := isGroup && routingOf(g.Routing) == provider.Ordered
inOrder := routingOf(p.Routing) == provider.Ordered
if isGroup {
inOrder = routingOf(g.Routing) == provider.Ordered
}
cands, pl, aff, stuck := affine(scope, mode, rotate, spread, inOrder, r.Header, from, body, plain, cands, pl)
// a strict conversation left with its own account of several: its
// failure rests the account as it would with the others still there,
@@ -0,0 +1,83 @@
package gateway
import (
"net/http/httptest"
"strings"
"testing"
"github.com/yetone/magpie/internal/provider"
)
// A provider's keys or accounts routed In order give a running
// conversation to the one the user put first at its next turn, as a group
// routed In order gives it to its first member (backToFirst): CryptoSarom
// on X made a new Codex account First, In order, and the conversation
// running on the old account stayed there, kept by its cache, until a 90%
// cap on the old one moved it. Within a turn it stays where the turn's
// reasoning was sealed; Smart, or Stays: Session, keep it where it is.
func TestOrderedAccountsGiveTheConversationToTheFirst(t *testing.T) {
for _, c := range []struct {
name, routing, mode string
want string // who answers turn 1, turn 2's two requests, turn 3
why string // the affinity of turn 2's first request
}{
{"in order", provider.Ordered, "", "k1 k2 k2 k2", "order"},
{"in order, Stays: Session", provider.Ordered, provider.AffinitySession, "k1 k1 k1 k1", "session"},
{"smart", "", "", "k1 k1 k1 k1", "cache"},
} {
t.Run(c.name, func(t *testing.T) {
fresh(t)
up := &cacheWriter{wrote: 3000}
srv := httptest.NewServer(up)
t.Cleanup(srv.Close)
save := func(first, second string) {
t.Helper()
p := provider.Provider{ID: "ord", Name: "Ord", Key: first, Keys: []provider.KeyAccount{{Key: second}},
Models: []string{"m1"}, Anthropic: srv.URL + "/v1", Routing: c.routing, Affinity: c.mode}
if err := provider.Save(p); err != nil {
t.Fatal(err)
}
forgetRouting()
}
save("k1", "k2")
s := New()
t.Cleanup(s.subscription.abortAll)
conv := `{"role":"user","content":"fix the bug"}`
var got []string
for i := range 4 {
if i == 1 {
save("k2", "k1") // the user makes k2 First
}
body := `{"model":"ord/m1","max_tokens":100,"tools":[{"name":"read","input_schema":{"type":"object"}}],"messages":[` + conv + `]}`
r := httptest.NewRequest("POST", "/v1/messages", strings.NewReader(body))
r.Header.Set("x-claude-code-session-id", "s-1")
rec := httptest.NewRecorder()
s.Handler().ServeHTTP(rec, r)
if rec.Code != 200 {
t.Fatalf("request %d: %d %s", i, rec.Code, rec.Body)
}
out := rec.Body.String()
switch {
case strings.Contains(out, "from k1"):
got = append(got, "k1")
case strings.Contains(out, "from k2"):
got = append(got, "k2")
default:
t.Fatalf("request %d answered by nobody known: %s", i, out)
}
if a := s.trace.routes[len(s.trace.routes)-1].Affinity; i == 1 && (a == nil || a.Why != c.why) {
t.Errorf("turn 2's first request: affinity %+v, want why %q", a, c.why)
}
if i == 1 {
// a tool loop: the turn goes on
conv += `,{"role":"assistant","content":[{"type":"tool_use","id":"t1","name":"read","input":{}}]},{"role":"user","content":[{"type":"tool_result","tool_use_id":"t1","content":"ok"}]}`
} else {
conv += `,{"role":"assistant","content":"done"},{"role":"user","content":"and more"}`
}
}
if g := strings.Join(got, " "); g != c.want {
t.Fatalf("answered by %s, want %s", g, c.want)
}
})
}
}
+3 -1
View File
@@ -239,7 +239,9 @@ func TestPluginFactoryStandardOnlyCaps(t *testing.T) {
back string // who the conversation goes to once A is back
}{
{"auto", "", false, "a"},
{"auto, cached on B", "", true, "b"},
// In order gives it back to A at its next turn whatever B
// cached (CryptoSarom on X)
{"auto, cached on B", "", true, "a"},
{"session", provider.AffinitySession, false, "b"},
} {
t.Run(way.name, func(t *testing.T) {
@@ -1133,7 +1133,9 @@ function routingPage(part) {
case "reserve": return t("{who} answered this conversation last, but it is in reserve while those before it in the list can take requests, so the conversation moves back to them.", { who: last });
case "credits": return t("{who} answered this conversation last, but it is on its credits now, set to spend them only after everything else, so the conversation moves to {first}.", { who: last, first: who(r.order[0]) });
case "gone": return t("{who} answered this conversation last, but it is no longer one to route to.", { who: last });
case "order": return t("{who} answered this conversation last, but the group goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.", { who: last, first: who(r.order[0]), n: a.turn });
case "order": return r.group
? t("{who} answered this conversation last, but the group goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.", { who: last, first: who(r.order[0]), n: a.turn })
: t("{who} answered this conversation last, but the provider goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.", { who: last, first: who(r.order[0]), n: a.turn });
case "main": return t("{who}, a fallback, answered this conversation last, but the provider's own {first} is ready again, so turn {n} goes back to it.", { who: last, first: who(r.order[0]), n: a.turn });
case "back": return t("{who} took this conversation while {first}, listed ahead of it in the group, couldn't; {first} is ready again, so turn {n} goes back to it.", { who: last, first: who(r.order[0]), n: a.turn });
case "no-cache": return t("{who} answered this conversation last, but the vendor then read only {r} tokens of it from its cache and wrote {w} — not worth staying for.", { who: last, r: tokens(a.cacheRead || 0), w: tokens(a.cacheWrite || 0) });
@@ -620,6 +620,7 @@ magpie.strings({
"{who} answered this conversation last, but it is on its credits now, set to spend them only after everything else, so the conversation moves to {first}.": "此会话上次由 {who} 回答,但它现在在用积分,且设为最后使用积分,所以会话换到 {first}。",
"{who} answered this conversation last, but it is no longer one to route to.": "此会话上次由 {who} 回答,但它已不可路由。",
"{who} answered this conversation last, but the group goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.": "此会话上次由 {who} 回答,但该组按顺序路由,排在它前面的 {first} 已恢复可用,所以第 {n} 轮回到 {first}。",
"{who} answered this conversation last, but the provider goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.": "此会话上次由 {who} 回答,但该提供商按顺序路由,排在它前面的 {first} 已恢复可用,所以第 {n} 轮回到 {first}。",
"{who}, a fallback, answered this conversation last, but the provider's own {first} is ready again, so turn {n} goes back to it.": "此会话上次由备用 {who} 回答,但提供商自己的 {first} 已恢复可用,所以第 {n} 轮回到它。",
"{who} took this conversation while {first}, listed ahead of it in the group, couldn't; {first} is ready again, so turn {n} goes back to it.": "此会话由 {who} 接手,当时组里排在它前面的 {first} 无法处理;{first} 已恢复可用,所以第 {n} 轮回到它。",
"{who}, a fallback, answered this conversation last. The provider's own {first} is ready again, but Stays is Strict, which never moves a conversation, so it stays on the fallback; new conversations go to {first}.": "此会话上次由备用 {who} 回答。提供商自己的 {first} 已恢复可用,但会话保持设为严格,从不移动会话,所以它留在备用上;新会话会走 {first}。",
@@ -1300,6 +1301,7 @@ magpie.strings({
"{who} answered this conversation last, but it is on its credits now, set to spend them only after everything else, so the conversation moves to {first}.": "此會話上次由 {who} 回答,但它現在在用積分,且設為最後使用積分,所以會話換到 {first}。",
"{who} answered this conversation last, but it is no longer one to route to.": "此會話上次由 {who} 回答,但它已不可路由。",
"{who} answered this conversation last, but the group goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.": "此會話上次由 {who} 回答,但該群組按順序路由,排在它前面的 {first} 已恢復可用,所以第 {n} 輪回到 {first}。",
"{who} answered this conversation last, but the provider goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.": "此會話上次由 {who} 回答,但該供應商按順序路由,排在它前面的 {first} 已恢復可用,所以第 {n} 輪回到 {first}。",
"{who}, a fallback, answered this conversation last, but the provider's own {first} is ready again, so turn {n} goes back to it.": "此會話上次由備用 {who} 回答,但供應商自己的 {first} 已恢復可用,所以第 {n} 輪回到它。",
"{who} took this conversation while {first}, listed ahead of it in the group, couldn't; {first} is ready again, so turn {n} goes back to it.": "此會話由 {who} 接手,當時群組裡排在它前面的 {first} 無法處理;{first} 已恢復可用,所以第 {n} 輪回到它。",
"{who}, a fallback, answered this conversation last. The provider's own {first} is ready again, but Stays is Strict, which never moves a conversation, so it stays on the fallback; new conversations go to {first}.": "此會話上次由備用 {who} 回答。供應商自己的 {first} 已恢復可用,但會話保持設為嚴格,從不移動會話,所以它留在備用上;新會話會走 {first}。",
@@ -1978,6 +1980,7 @@ magpie.strings({
"{who} answered this conversation last, but it is on its credits now, set to spend them only after everything else, so the conversation moves to {first}.": "この会話に前回応答したのは {who} ですが、今はクレジットで続行中で、クレジットは最後に使う設定のため、会話は {first} に移ります。",
"{who} answered this conversation last, but it is no longer one to route to.": "この会話に前回応答したのは {who} ですが、もうルーティング対象ではありません。",
"{who} answered this conversation last, but the group goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.": "この会話に前回応答したのは {who} ですが、このグループは順番どおりにルーティングし、その前にある {first} が再び使えるため、ターン {n} は {first} に戻ります。",
"{who} answered this conversation last, but the provider goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.": "この会話に前回応答したのは {who} ですが、このプロバイダーは順番どおりにルーティングし、その前にある {first} が再び使えるため、ターン {n} は {first} に戻ります。",
"{who}, a fallback, answered this conversation last, but the provider's own {first} is ready again, so turn {n} goes back to it.": "この会話に前回応答したのは代替の {who} ですが、プロバイダー自身の {first} が再び使えるため、ターン {n} はそちらに戻ります。",
"{who} took this conversation while {first}, listed ahead of it in the group, couldn't; {first} is ready again, so turn {n} goes back to it.": "この会話は、グループでその前にある {first} が受けられなかったため {who} が引き継ぎました。{first} が再び使えるため、ターン {n} はそちらに戻ります。",
"{who}, a fallback, answered this conversation last. The provider's own {first} is ready again, but Stays is Strict, which never moves a conversation, so it stays on the fallback; new conversations go to {first}.": "この会話に前回応答したのは代替の {who} です。プロバイダー自身の {first} は再び使えますが、維持が「厳格」で会話を移さないため、代替のままです。新しい会話は {first} に行きます。",
@@ -2658,6 +2661,7 @@ magpie.strings({
"{who} answered this conversation last, but it is on its credits now, set to spend them only after everything else, so the conversation moves to {first}.": "{who} hat diese Unterhaltung zuletzt beantwortet, läuft aber jetzt mit Credits, die es erst zuletzt verbrauchen soll, daher wechselt die Unterhaltung zu {first}.",
"{who} answered this conversation last, but it is no longer one to route to.": "{who} hat diese Unterhaltung zuletzt beantwortet, kommt aber für die Weiterleitung nicht mehr in Frage.",
"{who} answered this conversation last, but the group goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.": "{who} hat diese Unterhaltung zuletzt beantwortet, aber die Gruppe geht der Reihe nach vor und {first}, das davor steht, ist wieder bereit, daher geht Runde {n} zurück an {first}.",
"{who} answered this conversation last, but the provider goes in order and {first}, ahead of it, is ready again, so turn {n} goes back to {first}.": "{who} hat diese Unterhaltung zuletzt beantwortet, aber der Anbieter geht der Reihe nach vor und {first}, das davor steht, ist wieder bereit, daher geht Runde {n} zurück an {first}.",
"{who}, a fallback, answered this conversation last, but the provider's own {first} is ready again, so turn {n} goes back to it.": "{who}, ein Ersatz, hat diese Unterhaltung zuletzt beantwortet, aber {first} des Anbieters selbst ist wieder bereit, daher geht Runde {n} dorthin zurück.",
"{who} took this conversation while {first}, listed ahead of it in the group, couldn't; {first} is ready again, so turn {n} goes back to it.": "{who} hat diese Unterhaltung übernommen, als {first}, in der Gruppe davor, sie nicht annehmen konnte; {first} ist wieder bereit, daher geht Runde {n} dorthin zurück.",
"{who}, a fallback, answered this conversation last. The provider's own {first} is ready again, but Stays is Strict, which never moves a conversation, so it stays on the fallback; new conversations go to {first}.": "{who}, ein Ersatz, hat diese Unterhaltung zuletzt beantwortet. {first} des Anbieters selbst ist wieder bereit, aber Bleibt steht auf Strikt, das eine Unterhaltung nie verschiebt, daher bleibt sie beim Ersatz; neue Unterhaltungen gehen an {first}.",
@@ -16,14 +16,16 @@ const { chromium, webkit } = require("playwright");
// too, and says so ("back"; 01huadalang, 11-01: a MiMo backup kept a Codex
// session by its cache).
const words = {
en: { back: ["listed ahead of it in the group", "turn 2 goes back"], order: ["goes in order", "turn 2 goes back"], main: ["a fallback", "turn 2 goes back"], strict: ["a fallback", "Strict", "new conversations go to"] },
zh: { back: ["排在它前面", "第 2 轮回到它"], order: ["按顺序路由", "第 2 轮回到"], main: ["备用", "第 2 轮回到它"], strict: ["备用", "严格", "新会话会走"] },
"zh-TW": { back: ["排在它前面", "第 2 輪回到它"], order: ["按順序路由", "第 2 輪回到"], main: ["備用", "第 2 輪回到它"], strict: ["備用", "嚴格", "新會話會走"] },
ja: { back: ["受けられなかった", "ターン 2 は"], order: ["順番どおり", "ターン 2 は"], main: ["代替", "ターン 2 は"], strict: ["代替", "厳格", "新しい会話は"] },
de: { back: ["in der Gruppe davor", "Runde 2 dorthin zurück"], order: ["der Reihe nach", "Runde 2 zurück"], main: ["ein Ersatz", "Runde 2 dorthin zurück"], strict: ["ein Ersatz", "Strikt", "neue Unterhaltungen gehen an"] },
en: { back: ["listed ahead of it in the group", "turn 2 goes back"], order: ["the group goes in order", "turn 2 goes back"], accounts: ["the provider goes in order", "turn 2 goes back"], main: ["a fallback", "turn 2 goes back"], strict: ["a fallback", "Strict", "new conversations go to"] },
zh: { back: ["排在它前面", "第 2 轮回到它"], order: ["该组按顺序路由", "第 2 轮回到"], accounts: ["该提供商按顺序路由", "第 2 轮回到"], main: ["备用", "第 2 轮回到它"], strict: ["备用", "严格", "新会话会走"] },
"zh-TW": { back: ["排在它前面", "第 2 輪回到它"], order: ["該群組按順序路由", "第 2 輪回到"], accounts: ["該供應商按順序路由", "第 2 輪回到"], main: ["備用", "第 2 輪回到它"], strict: ["備用", "嚴格", "新會話會走"] },
ja: { back: ["受けられなかった", "ターン 2 は"], order: ["順番どおり", "ターン 2 は"], accounts: ["このプロバイダーは順番どおり", "ターン 2 は"], main: ["代替", "ターン 2 は"], strict: ["代替", "厳格", "新しい会話は"] },
de: { back: ["in der Gruppe davor", "Runde 2 dorthin zurück"], order: ["der Reihe nach", "Runde 2 zurück"], accounts: ["der Anbieter geht der Reihe nach", "Runde 2 zurück"], main: ["ein Ersatz", "Runde 2 dorthin zurück"], strict: ["ein Ersatz", "Strikt", "neue Unterhaltungen gehen an"] },
};
function routes(now, why) {
function routes(now, as) {
// "accounts": a provider routing its own keys In order, no group (CryptoSarom on X)
const why = as === "accounts" ? "order" : as;
const time = new Date(now.getTime() - 5000).toISOString();
const at = new Date(now.getTime() - 65000).toISOString();
const k1 = { id: "cw#k1", provider: "cw", name: "CW", kind: "key", who: "k1", model: "m" };
@@ -31,7 +33,7 @@ function routes(now, why) {
// Strict leaves the plan the one it keeps, and names the main beside it
const order = why === "strict" ? [k2] : [k1, k2];
return [{ id: 1, seq: 1, time, agent: "claude", model: "cw/m", provider: "cw", order, done: true, status: 200, ms: 20,
group: why === "order" ? { id: "g", name: "G", routing: "order" } : why === "back" ? { id: "g", name: "G", routing: "" } : undefined,
group: as === "order" ? { id: "g", name: "G", routing: "order" } : why === "back" ? { id: "g", name: "G", routing: "" } : undefined,
affinity: { mode: why === "strict" ? "strict" : "", turn: 2, last: "cw#k2", lastTurn: 1, at, cacheRead: 20000, cacheWrite: 3000, why, main: why === "strict" ? k1 : undefined },
tries: [{ id: order[0].id, model: "m", start: time, done: true, status: 200, ms: 20 }] }];
}
@@ -77,7 +79,7 @@ for (const engine of process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.waitForFunction(() => /\d/.test(document.body.innerText) && document.querySelector(".rt-cap")?.textContent);
return page.evaluate(() => document.body.innerText + "\n" + document.querySelector(".rt-cap").textContent);
};
for (const why of ["back", "order", "main", "strict"]) {
for (const why of ["back", "order", "accounts", "main", "strict"]) {
rs = routes(now, why);
const text = await story();
for (const w of words[lang][why]) assert.ok(text.includes(w), `${why}: ${w} not in\n${text}`);