01huadalang on Discord, after 76e4494db: Codex on several accounts in a
group with mimo2.6pro as the backup, Stays on Auto. Once Codex had quota
again, requests kept going to mimo.
The cause: when Codex couldn't answer, the turn fell over to mimo and the
session was stuck to mimo. On the next turns affine kept it there by
"cache", because only In order had a way back (backToFirst, Why "order").
A Smart group (and the other routings) never gave the conversation back to
the member ahead, however long Codex had been ready.
The fix: at the answer, the gateway records whether the member that
answered stood in for one listed ahead of it in the group: one that was
resting, or known all but used up (Used >= SpentShareOf). planGroup now
gives each candidate its member and its place in the group (placed), and
standsInFor reads the plan made before the tries. The flag is the stick's
stoodIn, inherited while the same who and model keep answering, and saved
in affinity.json (stoodIn). With Stays on Auto, a stick that stood in goes
back to the group's first member once that one is ready and not set aside
(backFromStandIn), with the new Why "back" and its Routing page line in
all five languages. A member put first on its merits (not a stand-in)
keeps its cache as before; Off, Session, Strict, Turn and In order keep
their own rules.
Not changed, by design: Smart and Least used count a key with unknown
usage (mimo) as unused, so with every Codex account at 90% or more of a
window a new session can go to mimo first. In order keeps a backup last;
the routing doc says so.
Tests (internal/gateway/group_stand_in_test.go, new):
- TestGroupBackupGivesTheConversationBack: smart auto with usage known
and unknown go back ("back"); in order auto "order"; in turn and smart
turn "new-turn"; smart off "off"; smart session, smart strict and in
order session stay on mimo.
- TestGroupBackupStandingInWhileTheFirstIsBackAndBehind,
TestGroupMemberPutFirstOnItsMeritsKeepsItsCache,
TestGroupStandInStaysWithinATurn, TestGroupStandInSurvivesARestart.
- affinity_fallback_test's TestGroupMemberKeepsTheConversationOnceAnother
IsBack pinned the old behaviour; it is now
TestGroupMemberGivesTheConversationBackOnceTheOneAheadIsBack.
- routing-affinity-order.test.cjs gains the "back" line.
Run, all on mote:
- With the non-test changes stashed (old code): both smart auto cases,
StandingInWhileTheFirstIsBackAndBehind, SurvivesARestart and
GivesTheConversationBackOnceTheOneAheadIsBack are red. Green with the fix.
- Broken by hand, each red: the "back" case off (smart cases,
StandingInWhileBehind); no inherit (StandingInWhileBehind); rest/spent
check off (usage-known case, StandingInWhileBehind); stoodIn check
dropped from the back case (PutFirstOnItsMerits); StoodIn not loaded
(SurvivesARestart). A check of failed tries stayed green when turned
off, since a failed try rests what failed, so it was removed.
- go test -tags nogui -count=1 -timeout 45m ./... at 80bcef18f + this:
every package ok except internal/gui, whose two reds are red on
origin/main d714c4216 too: TestSettingsSaveKeepsWhatItDoesNotSend
(#4514) and TestColdTurnsTaken (#4510).
- Rebased on 5a56bc7d7: internal/gateway, internal/provider and
internal/catalog ok; internal/gui has only the same two reds (#4514,
#4510). Main then moved three provider-only commits; at the pushed
parent f856d381a, internal/provider ok and internal/gateway -run
'Group|Affinity|Fallback|Ordered|Strict|Rotating|Stick' ok.
- gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet -tags nogui
./internal/gateway ok.
- GUI (Chromium and WebKit): routing-affinity-order, routing-js,
i18n-keys, gui-zh-tw and gui-de pass; gui-ja's one red is #4580
(a7b47d57e's string, not this one).
- Every routing-*.test.cjs file on mote (2050 tests, both engines, five
languages) at load 140 to 200 from other sessions' suites: 35 red in 10
files, all timeouts or moves under load. The same 10 files run alone,
serially, at this head and at origin/main 41b5c0f19 are red in the same
tests (27 and 30, differing only in which language flaked). All filed:
#4585, #3789, #3096, #3094, #3799, #3412, #1804, #4560, #3593, #4082,
#4627, #4628, #3954, #4629.
Not tried: no real Codex or MiMo account; the case was reproduced with a
fake upstream only. A stick saved before this change has no stoodIn, so a
conversation already stuck to the backup stays there until it goes cold
(5 minutes idle) or a new session starts.
01huadalang on Discord (#feedback): once a provider's main model works
again, a conversation that went to its Fallback while it was down stayed
on the fallback, with no switch to stop it. affine treated the fallback
as any answerer: Auto kept it while its cache was worth reading (each
turn read it again, so it never went cold), Session for the session, and
a rotating provider's new turn went to the one after the fallback.
A provider's fallback is now its emergency path. When the last answerer
is a Fallback row and the provider's own model stands first in the plan,
ready (restLast put it ahead, so its rest is over), the next turn goes to
the provider (backToMain, Affinity.Why "main"), in every mode but Strict,
which the user set never to move a conversation. Within a turn 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 either way. A routing group's members are never Fallback
rows, so a group's own affinity is unchanged. No switch was added.
"Ready" is unchanged: a rest ends when restAfter set it to (a minute and
backing off for a plain failure; the vendor's reset or Retry-After for a
quota or rate limit; quotaRest 15 minutes when nothing names a time), or
earlier when renewed or a background probe lifts it.
docs/subsystems/gateway-routing.md says this beside Strict.
Run (mote, at this commit's tree on origin/main 3ce2a9819, rebased onto 774baed6d (a one-line Qoder mover min); the new tests and internal/provider run again there, then onto 13b4a29ab (Desktop tier calls in internal/gateway): go vet and TestFallback|TestAffinity|TestDesktop|the new tests ok there):
- TestFallbackGivesTheConversationBackOnceTheMainIsReady red on the old
affinity.go: "next turn, main ready" and "..., session" answered from
spare-key, want main. Green with the change. With !a.Within dropped by
hand, "within the turn, main ready" goes red.
- TestGroupMemberKeepsTheConversationOnceAnotherIsBack green before and
after (a group member stays by its cache once another is back).
- gofmt -l clean; go vet, GOOS=linux go vet -tags nogui, GOOS=windows
go vet of internal/gateway: ok.
- go test -tags nogui -timeout 45m ./internal/gateway ./internal/provider:
ok internal/gateway 551.7s, ok internal/provider 108.4s
Not tried: a real account. The fake upstreams answer as Anthropic does
(a 429, then cache_creation_input_tokens 3000).