WorkBuddy and CodeBuddy name their conversation in X-Conversation-ID,
which sessionHeaders didn't list, so every WorkBuddy request had no
session: Routing put them all under "No session ID", and affinity, usage,
transcripts, OTel and a remote magpie lost the conversation too. The header
is appended last, so the aliases already read keep precedence, and the
vendor is never sent it.
Moved users are covered by the same line: the gateway gives a plugin the
session as ConversationHeader from conversationID(), plugins.go passes it
as FetchRequest.Session, and the WorkBuddy plugin derives its own
X-Conversation-ID from that. No plugin change is needed.
EdwinDigital's record (Windows ARM64, Go 1.26.8, temporary HOME):
- Removing only the alias makes TestWorkBuddySessionHeader,
TestWorkBuddySessionThroughGateway and TestRemoteMagpieKeepsTheSession
fail. They pass with -count=20.
- gofmt and git diff --check are clean. Windows go vet ./... and Linux
ARM64 go vet -tags nogui ./... pass.
- Installed WorkBuddy 5.8.2 (engine 2.161.0) ran against the patched
gateway and a loopback streaming mock. Two native sessions grouped 2+1,
with both titles resolved.
Review and run at this head (macOS, Go private cache, sandbox HOME):
- I read the patch line by line.
- The three tests pass. Commenting out the alias by hand makes all three
fail.
- gofmt -l is clean. go vet passes on darwin, linux -tags nogui and
windows.
- go test -tags nogui -count=1 -timeout 40m ./internal/gateway/: ok (811s).
Not tried by me: a real WorkBuddy or CodeBuddy client, and real vendor
calls. EdwinDigital ran WorkBuddy against a mock.
Kenoia: Pi's X-Magpie-Session and session_id were lost on the hop to a remote magpie, so the remote recorded no session and keyed its affinity by the first user message, which two sessions can share. As reported: forwardOnce builds a fresh request and copies the client's own headers only for Codex (fromCodex) and Claude Code, and passOnCaller, the remote-magpie step, set only X-Magpie-Agent and X-Magpie-Via; sessionOf, nativeSessionOf and conversationID on the remote then found nothing. A Responses body's prompt_cache_key was never touched.
withCaller now also notes the caller's X-Magpie-Session and the first of the agent's own session headers nativeSessionOf reads (session_id, x-session-id, x-opencode-session, ...), by its name, trimmed and at most 128 bytes, and passOnCaller sets them on the request to a remote magpie, so Chat, Responses, Messages, drawings and videos passed on all carry them. passOnCaller is called only for a remote magpie provider, so no vendor is sent them.
TestRemoteMagpieKeepsTheSession (two gateways in-process: a Pi request with X-Magpie-Session and session_id to a Remote magpie provider, on /v1/chat/completions and /v1/responses with a prompt_cache_key) fails on the old code (the remote was sent neither and recorded no session) and passes: the remote is sent both, records session and native session, and the vendor behind it sees neither header. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried between two real computers.