crypto0xfish on Discord, the Codex app: "Model provider mismatch. This chat uses OpenAI, but your current provider is magpie. Switch to OpenAI to continue." magpie makes itself Codex's provider (model_provider = "magpie") when Codex has no ChatGPT sign-in, is signed in with an API key, the user picks magpie API, or the ChatGPT account is used up (the takeover). bringOver then moves OpenAI's threads to magpie, a paginated one by its row (RetagPagedCodexThreads), skipping any a Codex holds open (its writer lock) or wrote to in the last minute, "for the next sync". The Codex app holds the lock of every thread it has loaded, the chat on screen among them, however long ago it was written (tried below), and nothing asked for that next sync: Sync runs on catalog changes, which can be hours away. So the chat open at the switch stayed on OpenAI; the app refuses it while loaded (app-server check_thread_model_provider_for_input compares the loaded thread's provider with config.toml at each turn), and after the app let it go it was refused again on resume by its row, until something else synced.681a472cafixed the same gap for bringBack by time alone and named the held-lock case as not tried. - sessions.CodexThreadsBusyOn also counts a thread on the provider whose writer lock a Codex holds (codexLockedIDs: the lock files in thread-writer-locks, each tried and let go under Codex's coordination lock, none made or removed). - codexThreadsLater(dir, p) now looks every 15s, for up to 12h, and asks for the Sync once nothing on p is busy or held; one wait per home and provider. bringBack keeps calling it for magpie; bringOver calls it for the provider it moved from, and lendOwn for openai (the same skip, OpenAI's threads onto a provider of the user's). - Tests: TestCodexOpenThreadFollowsMagpieOnceLetGo (new: a paginated OpenAI thread held open stays at the takeover, no Sync is asked while held, one is once let go, and that Sync moves it to magpie); TestCodexTakeoverThreadComesBackOnceQuiet now expects the Sync only after the thread is quiet. TestMain turns the wait off so no goroutine outlives a test; the two tests end theirs in Cleanup. - docs/subsystems/agent-wiring.md says so. The chat loaded at the moment of the switch can't be helped from outside: the app goes on with it once it reloads it (quit and reopen). Codex's identity line, base_instructions and every value of the user's are untouched. Run on mote at this tree (basecff530079): - gofmt -l: clean; go build ./...: ok; - go vet ./internal/agent ./internal/sessions for darwin, linux -tags nogui and windows: clean; - the two tests with -race -count=3: ok; - go test ./internal/agent ./internal/sessions: ok. On Windows (win-run): the two tests and TestCodexPagedThreadsFollowByRow: ok. Broken by hand: bringOver's call turned off (`if false &&`), the new test fails "no later Sync asked for"; the lock check in CodexThreadsBusyOn turned off, it fails the same way. Restored, both pass. Real Codex: codex-cli 0.165.0's app-server in a sandbox CODEX_HOME, a thread started and a turn sent (to a dead fake provider). With the thread loaded and its rollout quiet 73s, its lock was held, a probe built from this tree said CodexThreadsBusyOn true and RetagPagedCodexThreads moved nothing; after the app-server exited and a quiet minute, busy was false and the retag moved the row. Not tried: the real Codex desktop app (whether leaving a chat for another lets its lock go within a minute, or only quitting does), and a live switch with a real used-up or API-key account. The reporter's own setup (why Codex was on magpie for them) is not known. Reported-by: crypto0xfish
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.