Derive a session scope from x-magpie-session (magpie's synthetic
magpie-<24hex> id ignored, capped at 128) and x-magpie-subagent (capped
at 64), from init.headers or a Request's headers, and key conversations,
live-session reuse, clientSeen and tool-result matching by it. A forked
session or a subagent carrying its parent's tool_use history no longer
collides with the parent's convKey or toolCalls (409 conflicting
duplicate result, lineage_fork superseding the parent's pending turn).
A body given only on a Request is read from it.
Contributed by @wjhauannn.
Run at 46fce29f (mote, macOS, HOME=$(mktemp -d)):
- node --test repeat-batch.mjs conversation-key.mjs: 97 pass, 0 fail.
- bun test packages/agy-cli: 37 pass, 0 fail. check.mjs agy-cli: ok.
- CI: test, bumped, on-npm green.
Broken by hand: origin/main's index.mjs with the new tests: 5 fail
(55, 56, 57, 59, 60).
Checked against magpie main: the gateway sets x-magpie-session
(sessionOf) and x-magpie-subagent (subOf) on plugin requests only. A
spare takes the scope through #assign on adopt.
Not tried: a real agy account with a forked Claude Code session.