Files
magpie/docs
yetone b92cb2f596 gateway: another magpie's request is masked and shown in flight under its agent (linkaww)
linkaww on Discord: Pi through a local magpie to a remote magpie with
masking on. The remote's masking log named the request "magpie", while
its usage already said Pi. The local magpie already sends the agent
(X-Magpie-Agent / X-Magpie-Via, passOnCaller). The remote's masking log
read agentOf, the real sender, instead of callerOf, the recorded label.
So the fix is on the remote: only the remote magpie needs this version.

There is one rule now, callerFrom/callerOf, for every place the remote
says who sent a request:
- the masking log (noteMasked)
- the requests in flight (/v1/magpie/concurrency). counted runs before
  withCaller, so active.add calls callerFrom itself.
- observed calls
- Codex title / tool-loop answers (answeredHere)
- Codex search and backend records, which recorded agentOf
Usage and sessions already used callerOf. The trust rule is unchanged.
The headers are taken only from a magpie/ User-Agent and are a label
only: access, key limits and behaviour (middleware Info.Agent, models
shown, stand-ins, group rules) still go by the key and agentOf. A client
that isn't magpie is logged as itself.

Run:
- go test -tags nogui -count=1 -timeout 45m ./internal/gateway: ok
  (562s) at bdd6a6c73, this change on 1cbdda25b
- after rebasing onto 430e3050d: go vet (darwin, GOOS=linux,
  GOOS=windows, -tags nogui) ./internal/gateway, gofmt -l, and -run
  'TestRemoteMagpie|TestMasked|Active|Concurrency|CodexTitle|ToolLoop':
  ok
- Two sandbox magpies on 127.0.0.1:47611 (remote, masking on, a fake
  upstream on :47613) and :47612 (local, a Remote magpie provider to
  :47611), each under its own HOME/XDG dirs. A Pi request
  (Bearer magpie-pi) carrying an API key went through the local. With
  the remote on origin/main, its masking/<day>.jsonl line said
  "agent":"magpie" and its usage said "pi". With the remote on this
  change, both said "pi". The upstream got the key masked.

Broken by hand: masked.go back to agentOf made
TestRemoteMagpieMaskedNamesTheAgent fail ("logged as \"magpie\", want
pi"). active.go back to agentOf made TestRemoteMagpieActiveNamesTheAgent
fail (Agent:magpie).

Not tried: the GUI's Privacy page on the remote. It shows the record's
agent field, which the jsonl above has. A remote reached through a
Claude Code or Codex client User-Agent (passUserAgent): there the remote
reads that agent from its own User-Agent, as before.
2026-10-27 15:53:54 +08:00
..