sufeng1894 asked why Codex's compaction threshold can no longer be set by hand. The card said config.toml's model_auto_compact_token_limit wins, and the background row said features.async_compaction's model_async_compact_threshold_percent wins: both locked, and nothing on the card did anything about it. Cause. Only the old tune card (9e665491etof20118304, 10-10 to 10-28) wrote model_auto_compact_token_limit, stashing the user's own raw value; the 10-28 migration puts that raw value back, which then locks the card. So the values on the screen are the user's, or the user's restored by that migration. A magpie-written value could have lost its stash through stash.json races (before270b52573), an unparsable stash (before58651568b), tuneMigrateCodex forgetting the stash even when its file write failed, and codexAsyncSync stashing only after every write. The last two are fixed here: the migration forgets only after the write succeeds, and codexAsyncSync records its stash in a defer right after reading the old state, advancing it per successful write. Change. A locked card shows one button, "Let magpie set it" (zh 交给 magpie 设置, zh-TW, ja, de), only when the user clicks. POST /api/tune/takeover (TuneTakeOver): - the file's limit moves into Long conversations by tuneMigrateCodex's rule (a lower Long the user has is kept), the key is deleted from config.toml with every other key kept, and the file value is stashed (tune.codex.compact_file); Undo puts Long back and writes the key back, unless the user changed Long since; - a background threshold of the user's (enabled = true) is adopted as magpie's background share with its own Undo, which turns the share off and gives back the percent and enabled as they were. enabled = false is not taken. Nothing removes the user's value without that click. Run: - internal/agent, internal/gui, internal/cli, internal/tune at the pushed head (rebased onca87ae9c5) on mica: ok. TestCoreScriptBudget raised by 189 (the button, its post and Undo background), reason in the file. - Full Go suite -timeout 45m on mica at the pre-rebase head (2ba62f7f7base): every package ok except TestCoreScriptBudget, since fixed. - Broken by hand, red: migrate forgetting first (TestTuneCodexMigrateKeepsStash), asyncGiveBack disabled (TestTuneCodexTakeOverAsync), longUndo in place of codexLongUndo (TestTuneCodexTakeOver), and the GUI button disabled (context-tune, 11 red). - context-tune, compact-one-value, codex-async-compact, i18n-keys at the pushed head on mica, Chromium and WebKit, every language, 360 and 1100: the new test passes; reds are codex-async-compact's zh/zh-TW "kept the share out" (4, the same atca87ae9c5) and i18n-keys' routing plugin word (#6877). - win-run TestTune|TestCodexAsync in agent and gui: ok. wsl-run vet and those tests with -tags nogui: ok. GOOS=windows go vet and GOOS=linux go vet -tags nogui: ok. gofmt -l: clean. - make test-ui on mote, pre-rebase head, through header-centre (about a third; the rest still running when pushed): reds in 29 files, none a tune file. The first 16 (account-arrange to context-cap) were run alone at this head and at origin/mainca87ae9c5on mica: the same reds at both (base has 4 more, in agent-own-direct), the #5475 class. The next 13 (ctx-session-line to header-centre) were run the same way at the pushed head: 59 red at head, 60 atca87ae9c5, the same tests (header-centre's halfway case red in one engine at each). Not tried: a real Codex session after the takeover; codexAsyncSync's defer has no test with a failing write.
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.