Files
magpie/internal/gateway
yetone 593ea437d8 gateway: a Codex conversation's prefix is sent the same on every request
@m0eaki on X: LobeHub's Codex 0.169 on magpie, the prompt cache holding
only through the base instructions, the skills_instructions message
differing from turn to turn. Codex 0.169 puts its skills, permissions,
deferred tools and <model_catalog> in one developer message, and magpie
writes that message again when it widens the catalog with the models a
subagent may be put on (spawnAgentModels), so it is the one place magpie
could change it.

TestCodexPrefixSameOnEveryRequest posts Codex 0.169.0's request with
LobeHub's app-server headers through the whole handler: a turn's request
twice, the next turn, after a restart and 20 times over on fresh servers,
with two providers and a routing group in the catalog, and checks every
input item up to the new ones is the same bytes upstream. It passes:
magpie's widening is already stable, and magpie never writes or reorders
<skills_instructions> itself. Nothing in magpie is changed.

What does vary is Codex's own: run in a sandbox CODEX_HOME
(workspace-write), Codex 0.169.0 writes the working folder into the same
message's writable roots, so a host that starts turns in different
folders changes it. Codex's skills block itself was the same bytes across
fresh processes (0.165.0, 0.169.0).

Broken by hand: shuffling spawnChoices' list turns the test red at "the
same request again: input[1] differs".

Run (mica, mica-run):
- go test -count=1 -timeout 45m ./... at 3869aee3b with this commit: 99
  packages ok, 5 red, none in code this commit touches:
  - internal/agent TestWSLAgentFolderIsALink (#7150)
  - internal/dirent watch tests, five of them (#7031)
  - internal/gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes
    (#7117, red on origin/main)
  - internal/gui TestGatewayModeListsNoOwnSessions (#7064)
  - internal/sessions timed out at 45m (2700.7s), and again run alone
    (2701.5s, TestStatsMidnight at the deadline); noted on #5451
- rebased on origin/main ef997d186: go vet
  ./internal/gateway ok; go test -count=1 -timeout 45m ./internal/gateway
  (1172s): only #7117 red, TestCodexPrefixSameOnEveryRequest and the
  TestSpawnAgent* tests pass.
- rebased again on origin/main ddc78405c (this push's parent, two
  gateway commits on): TestCodexPrefixSameOnEveryRequest and
  TestSpawnAgent* ok.
- gofmt -l over every tracked .go file: clean.

Not tried: a real LobeHub conversation through magpie. The reporter's two
captured item-2 texts would show which line changes.
2026-11-19 14:21:43 +08:00
..
gateway tests: a Chat client's reply translated from Anthropic's Messages streams as the vendor sends it — the first chunk when its first event comes, each word as it is written, never the whole reply held to the stream's end — and now a test holds it to that. A reporter's OpenAI-format client on Z.ai's GLM saw the opposite for a while (every event of a reply in one burst once the stream ended, while the same provider's Messages replies streamed fine), and it measured out to be the vendor's doing, not the gateway's: the reporter's own request bodies, replayed at full size against the vendor's chat and Messages endpoints through the gateway's build and beside it, streamed both ways on the day. Nothing locked the translation's pacing, though, so a future hold would read as the vendor's again. TestChatFromAnthropicStreamsAsItComes paces a Messages upstream at 200ms a word — glm-5.3 at an Anthropic-only provider, and a Claude model where Chat and Anthropic URLs both sit, which the Messages redirect takes there anyway — and wants the client's first chunk before the upstream has written its last word (relative to the upstream, not the wall clock, so a loaded runner's setup time is not held against it), at least two of the five pauses reaching it, and one ask on /v1/messages; holding every event of the chat encoder until finish (as the report read) fails it on both branches with the first chunk at the stream's end. And the keepalive table that walks every protocol's quiet stream (TestQuietStreamsKeptAliveEveryProtocol) had responses, anthropic, chat and anthropic from chat; chat from anthropic, the path a chat client on a Messages-only provider takes, was the row missing, and it keeps alive the same as the rest. go test -race -count=2 on the two tests, go vet and the nogui build pass. (#1310)
2026-10-14 15:28:27 +08:00
wip
2026-11-12 12:45:39 +08:00
wip
2026-11-12 12:45:39 +08:00