ysm119 on Discord: each Restart of Codex in magpie left the ChatGPT desktop app on "ChatGPT 遇到了问题 / 请重试" till it was quit and opened again. magpie ends the app's own app-server cleanly (code 0); a signed-in ChatGPT 26.1021 then fails "Hosted AppServerManager identity is not ready" on the one it starts, logs fatal_error_broadcasted and shows the page. That is the app's bug; magpie now follows it up. - provider/codex_app_crash.go: for 60s after every end magpie makes (the watcher's step, RestartCodexApp, RestartSwitchedCodexApp) the app's logs are read for a whole fatal_error_broadcasted line stamped after the end. On one, with no request through magpie since or in flight and no Codex turn opened since, the app is quit and opened once. Otherwise it is left as it is and logged. Where it can't be reopened (Linux, an app that didn't quit) the Agents row says "The Codex app hit an error · quit it and open it again" (appSnag) until the app-servers seen then are gone or the app is closed. Unreadable logs reopen nothing. - agent/codex_app_crash.go: the logs as the app's file logger writes them (macOS ~/Library/Logs/com.openai.codex, Windows %LOCALAPPDATA%\Codex\Logs and the Store package's LocalCache, Linux $XDG_STATE_HOME/codex/logs; YYYY/MM/DD folders, tail-read, half lines dropped). The relaunch is the Agents row's: on macOS ChatGPT.app found by its bundle id, quit as ⌘Q does and opened once it has ended, never forced; on Windows codexAppReopen. - GUI line in en, zh, zh-TW, ja, de; docs/subsystems/agent-wiring.md. Run on mote (macOS) at this head on origin/main08982805e: - go vet ./internal/agent ./internal/provider ./internal/gui (darwin and GOOS=windows), GOOS=linux go vet ./internal/agent ./internal/provider; go build ./...; gofmt -l clean. - go test ./internal/provider ok; go test -run 'TestCodexApp|Restart|Reopen' ./internal/agent ok. - go test ./internal/gui: red only in TestMainWindowCorners (#3949) and TestPanelHiddenByWailsMarksPageOutOfSight (#5322), AppKit window tests red on mote's macOS 27 and filed before this change. - win-run and wsl-run: go test -run TestCodexApp ./internal/agent ./internal/provider ok (the macOS relaunch test skips on Windows, as TestWorkBuddySidecarOutlivesQuitOnMac does, #4115). - node --test codex-app-snag, codex-app-out, codex-app-back, i18n-keys, i18n-en-no-cjk: chromium and webkit, every language, 980 and 440px. i18n-keys' "a plugin's words are its own" stays red for "View routing" (#5327/#5332, red on main since73c98ebc2); this change added a word there and took it out again. - Core script budget: under it, not raised. Broken by hand, each red then restored: - codexAppCrashStep's call removed: 4 provider tests red. - the watch not armed in RestartSwitchedCodexApp: TestCodexAppRestartsWatchForTheErrorPage red; in RestartCodexApp: TestCodexAppRowRestartWatchesForTheErrorPage red. - the turn and request checks off: TestCodexAppInUseAfterItsErrorPageIsLeft red. - the snag not set: TestCodexAppSnagSaidTillTheAppRestarts red. - the stamp's >= since check dropped, or a half-written last line kept: TestCodexAppCrashedReadsItsOwnLogs red. - a wrong Store package path: TestCodexAppCrashedReadsEachSystemsFolder red. Not tried: a real signed-in ChatGPT app reaching the identity-not-ready page, and a real quit and reopen of the user's ChatGPT.app (the relaunch is tested with faked process listing, quit and open in a sandbox HOME). The log line and folders are read from ChatGPT 26.1021's file-based-logger and the reporters' logs; a later app that renames them reopens nothing, as before this change.
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.