Codex names a subagent's request (x-openai-subagent: collab_spawn), and the Routing page tags its row Subagent, with why it went where it did. Claude Code names no kind, so Claude Desktop's subagent turns, which magpie now moves to their own model and effort, read as the lead's: a Desktop session's rows on one routing group could not be told apart. Claude Code 2.1.295 sends x-claude-code-agent-id from every agent context but the main one. Its x-claude-code-request-class and x-claude-code-agent-type hints go only to a first-party base URL or with CLAUDE_CODE_GATEWAY_HINT_HEADERS, so magpie doesn't get them. - subagentTurnOf keeps the id in Route.SubagentID for a request that offers tools and names no kind: the turn desktopSubagentPick and desktopSubagentEffort take. Desktop's and terminal Claude Code's turns are kept, moved or not. The lead's turns, a subagent's tool-less helper calls (#2081: Claude Code's housekeeping) and a blank id are not. A kind wins over the id. - A Desktop pick or effort that found the turn is trusted, so the body isn't decoded again; a request without the id isn't decoded at all. Only a subagent's turn with neither setting reads its tools once. - Kind stays empty (#2081), so the ledger, the Usage page and the Purpose filter keep the turn unmarked. The ledger's Subagent already keeps the same id, on the helper calls too. - routing.js tags it through tagKind in the request list (by request and by session), the story, the replay and the tray panel, with Codex's words and reasons (kindWhy's collab_spawn: moved or kept, within a routing group, on the model asked for). No new strings. - The day's history keeps the id. A route kept before it has no tag, and its moved/kept story reads as before. Verified at this head, onb9c589eb, under a temporary HOME with Go's caches pinned: - Each new test fails with its guarantee broken by hand (a real FAIL, not a build error), then passes restored. Go, 10: the id never set; tools, kind or the trusted pick ignored; tools decoded before the header (the lead's request then allocates 10 times, 1 for its headers); the route not given the id; Desktop only (terminal fails); every request trusted (the helpers fail); the JSON key renamed; the field left out of the history. GUI, 8, each 0 pass / 4 fail (Chromium and WebKit, 1100 and 420, zh) at its own assertion: tagKind ignoring the id; the list, the story, the replay or the panel testing Kind alone; kindWhy's collab_spawn reasons on Kind alone; the id over a kind; the Purpose filter following the tag. - go test -tags nogui ./...: 53 packages ok. - go test -race -count=20 -run '^(TestSubagentTurn|TestHistoryKeepsSubagentID|TestDesktopSubagent)' ./internal/gateway: ok. - gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./..., go build, GOOS=linux go build -tags nogui, GOOS=windows go build: exit 0. - claude-subagent-tag.test.cjs: 20/20 (Chromium and WebKit; en, zh, zh-TW, ja, de; 1100 and 420), three runs in a row. - Desktop-bundled Claude Code 2.1.295 through the built gateway, a temporary HOME, a loopback-only sandbox and local fixture replies, its Agent tool spawning a real subagent: with nothing set, with a subagent model, and as terminal Claude Code, each run kept 4 routes; the subagent's one turn has the id the client sent upstream, the lead's 3 requests none, Kind empty; the model pick moved it to m2. No tool-less helper call came in these runs; the Go tests cover them. - The Routing GUI tests around it, 91 files (every routing-*, the tray panel's two, purpose-filter, click-scroll, the Codex and Desktop subagent files, subagent-effort, search-instead, search-mcp, vision-mcp, remote-group-served, reasoning-speed, usage-ledger, sessions-overview and the new one), six files at a time: Chromium 602/617, WebKit 572/617. Each failure fails without this commit too. Onb9c589ebuntouched (checked for the effort commit): routing-days-fit, routing-failed-open and routing-side-calls in both engines (their position checks against #2134's at-top rule), routing-wb-restricted (#2115's wheel), and at 420 in WebKit routing-agent-gone, routing-agent-hue-not-red, routing-rest-off and routing-held-member. On 6926b7ce: search-instead in WebKit, 5 of 5 alone, and routing-context-fold's picked request in WebKit, a row out of view, 2 of 5 runs alone there and 3 of 5 here. Not run: the whole GUI suite, a real Claude Desktop window or Cowork, Linux and Windows machines (GOOS vet and build only), WebKitGTK.
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 |
| 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 |
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.