01huadalang on Discord, after76e4494db: 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 ./... at80bcef18f+ this: every package ok except internal/gui, whose two reds are red on origin/maind714c4216too: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestColdTurnsTaken (#4510). - Rebased on5a56bc7d7: 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 parentf856d381a, 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/main41b5c0f19are 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.
Subsystem design references
These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.
| Subsystem | Reference |
|---|---|
| Built-in subscriptions moving to plugins | Provider and plugin ownership |
| Built-in plugins: registry, lifecycle, plugins.yml, presets, settings schemas, the window's kernel (slots, error boundary, kit) | Plugin runtime |
| Plugins that run on the gateway's requests and replies | Gateway middleware |
| Tools that plugins give, offered to every agent as an MCP server | Plugin tools |
| Plugins that await context recall and observe completed replies | Asynchronous gateway request hooks |
| Claude subscription turns across Claude Code runs | Claude subscription bridge |
| How the gateway picks a provider, key or account, and falls back | Gateway routing and fallback |
| Gateway Session Aggregation | Gateway Session Aggregation |
| Connecting an agent's config to the gateway, drift, disconnect, WSL twins | Agent wiring |
| Providers, keys, subscription accounts, refresh and allowance | Providers and accounts |
| Instructions, MCP servers, skills and RTK written into agents | Library |
| One MCP server, magpie, given to every agent in place of the Library's servers | MCP router |
Tray, panel, window, magpie web and the page's JSON API |
GUI app shell |
| Encrypted backups and setup synchronization over WebDAV, S3 or GitHub | Sync and backup |
A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.
Maintain a reference
Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.
Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.
For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.
Describe a PR's semantic changes
For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.
For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.
This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.
Review a change
- Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
- Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
- Check that changed contracts appear in the owning reference and that source links still resolve.
- Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.
A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.