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, on b9c589eb, 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. On b9c589eb
untouched (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.