xiaoq6285 on Discord (v0.1.2700): Codex on an official ChatGPT account ran out of quota, and after switching to another account or provider in magpie, the Codex app's Send button stayed grey. magpie has no chat composer of its own; the button is the Codex app's, which greys Send for every model while the app-server it runs is on a ChatGPT account the app holds. magpie lifts that by restarting the app's app-server (codexAppStep), but never while a Codex turn is open in its sessions, for up to codexTurnWindow (30m). When quota runs out mid-turn the turn is left open, so the restart, and the grey, waited.cc81ad4ealet a quiet stuck turn be restarted past (codexTurnStuckAfter, 2m) only after SwitchWhenSpent's own switch. Two siblings that leave the app-server on the same used-up account still waited the 30 minutes: - a switch by hand (Accounts, CLI) off an account last read held: noteCodexSwitch now marks it spent when the account's reading in hand says Held (codexHeldKnown: cache only, no I/O; a failed read or none is not held); - magpie becoming Codex's provider for the used-up account (codex.out): codexAppStep marks the change into out spent. The way back at the reset still waits for any open turn, as a real one may run there. A turn still writing its session or sending through magpie in the last 2 minutes holds the restart as before. Tests, both red on the old code: - TestCodexAppServerRestartedPastATurnStuckWhenMagpieTakesOver - TestCodexHandSwitchOffAHeldAccountIsSpent docs/subsystems/agent-wiring.md says so. Run at this head on mote: - go test -tags nogui ./internal/provider: ok (151s), at this head after the rebase on52195b6b0(it changed provider_test.go and two more provider files, so provider was run again). - Before the rebase (on07f4d46c5): provider ok, agent ok, gui ok; gateway red on TestCodexPoolSaysTheClientsVersion alone (#4807, red in a full package run, passes alone; -count=5 alone ok at this change); cli red on TestEveryRouteHasACommandOrIsNamed (#4826), red the same on origin/main52195b6b0just fetched. - gofmt -l clean; GOOS=linux go vet -tags nogui, GOOS=windows go vet and go vet of ./internal/provider ./internal/agent ok at this head. - Not run: the full go test ./... (agent, gateway, gui, cli and provider are what reach this code). No GUI change, so no GUI suite. Broken by hand, each red, then restored: - spent not set on the takeover (c.spent && into): the takeover test failed "a turn stuck on the used-up account as magpie took over: ended [], want [60]". - noteCodexSwitch never marking spent: the hand-switch test failed "switched off out@x: switched true, spent false, want true, true". Not tried: the real Codex app with an account actually out of quota (no such account to hand), and Windows/Linux runs of the package (the change is OS-independent logic; GOOS vet run). Not confirmed with the reporter that their case is a turn left open; their screenshot wasn't seen here.
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.