An Azure subscription with a spending limit (a student's $100 a month, a trial's) is disabled by Azure when its credit runs out and enabled again on its own when the credit renews. Meanwhile every request 401s "Access denied due to invalid subscription key or wrong API endpoint", the words a wrong key gets. magpie read that as any 401: failOther on the 1-minute backoff climbing to 10 minutes, never asked in the background, so the key was asked again by requests for weeks, and the reporter turned the provider off and on by hand around the reset day. Now restAfterMarked reads a failOther 401 as failSuspended when azureSuspended holds: no account, Provider.IsAzure, and the key has answered a request before (provider.LastServed at provider.ServedID, served.json, 30 days) or is resting suspended already. It rests suspendedRest (a day) by "suspended", and probeable takes it whatever its status: keepProbingRests asks the resource's deployments list with the key at 1, 2, 5 and then every 10 minutes (refused the same while the subscription is off) and lifts the rest as soon as the list answers, or when a request does. Its group's requests go to the next member meanwhile, Azure not asked. Product calls (mine to make, delegated): - One 401 is enough, not "repeated" ones: a 401 is about the credential, never the model or the request content. On a key that worked, a transient 401 is lifted by the first ask a minute in, the same as the old one-minute backoff let it back. - A bad key stays a bad key: a key 401 from its first request (new, mistyped, or edited, its KeyID then another) has no answer on record and rests as before, failOther/backoff, shown "401 · failed", never asked in the background. served.json unreadable is no answer on record too (a failed read is unknown, not "it worked"). - Azure only: a 401 says nothing of why on other vendors, and a list that answers without the key (OpenRouter's is public) would lift a key its vendor still refuses. - No "back on day N" setting: the probe finds the day Azure enables the subscription, so there is nothing for the user to type in, and no Advanced field. GUI: the key list says "Resting · 401 suspended by the vendor · back at … · checked in the background, back as soon as it answers"; Routing's restHow says its key answered before, so the vendor has most likely suspended it (an Azure subscription out of credit). KEY_FAIL and the routing plugin's FAIL gain "suspended", in en, zh, zh-TW, ja and de. keyDead is unchanged, so "Remove failing" doesn't offer a suspended key. docs/subsystems/gateway-routing.md has the rule beside the rest probe. Not covered: a 403; a key whose last answer is over 30 days old after a restart (rests are in memory); the last candidate of a request, which rests only for quota, credit or a timed rate limit, so a lone Azure provider is asked again by each request, as before, and answers as soon as Azure does. Run on mica (mote had other sessions' full suites), at b4c88d44e unless named, rebased on9fc1114d8before the push: - go test -tags nogui -run 'TestAzureKey|TestSuspended' ./internal/gateway: ok. Broken by hand, each red: azureSuspended always false (3 red: ThatAnswered, IsAzureOnly, OutlivesItsLastAnswer); served history ignored, every Azure 401 suspended (NeverAnsweredIsABadKey and OutlivesItsLastAnswer red); probeable's suspended branch off (ThatAnswered, IsAzureOnly red). - azure-suspended.test.cjs, chromium and webkit, en zh zh-TW ja de, 1100 and 420px: 40/40; with the base's four GUI assets, 0/40. - At this head rebased, on mote (mica had another session's GUI suite): rest-try-now, key-rest-date, rest-probed, azure-suspended, routing-rest-off and i18n-keys, both engines: 146 of 164. All 18 reds are rest-try-now's (#4127 "ebody holds", #2564), 18 of 40 at origin/main9fc1114d8too. At b4c88d44e under load 47 on mica the same files had 50 timeouts; at light load only rest-try-now's, red on main too, are left. - go test -count=3 -run 'TestAzureKey|TestSuspended|Probe|Rest' ./internal/gateway at this head rebased, on mote: ok. - go vet ./internal/gateway ./internal/gui, and GOOS=linux and GOOS=windows go vet ./internal/gateway: ok. - go test -timeout 45m ./... in a sandbox HOME: the first run filled mica's disk (another session's) and ~300 tests failed "no space left on device". The six packages it touched, run again: agent and provider ok, sessions ran past -timeout 45m with no test failed (TestTitleOfALongPromptAllocatesItsTitle at the deadline, #5451; it imports neither gateway nor gui); three reds, each filed and none in code this changes: - internal/dirent watch tests (#7031), red at origin/main9fc1114d8too. - TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117), red at9fc1114d8too. - TestGatewayModeListsNoOwnSessions (#7064, the listing race): red 2 of 3 at b4c88d44e, ok 2 of 2 at9fc1114d8and 4 of 4 at this head rebased. Not tried: a real Azure subscription disabled for its credit (none to hand); the list's 401 while disabled is from Azure's documented behaviour that the data plane refuses a disabled subscription's key on every route.
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 |
| Memory shared by every agent: the memory MCP server, the digest in instructions, the Memory tab | Memory |
| One skill, magpie-skills, listing the Library's skills in place of each agent's own | Skill 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.