Files
magpie/docs
yetone 5ee9a18747 gateway: magpie's own summary ask keeps its status, so a compaction over the byte cap is summed up locally (#4862)
codexCompact asks a summary through the gateway's own handler (wantsWhole)
and reads a 413 as its cue to fit the conversation, then to sum it up
without a model. That ask was treated like a client's turn:

- with Codex's User-Agent, compactsInStream sent it a 200 and the 413 as
  the stream's error, so codexCompact saw no 413 and answered 502 "so
  there is no summary" for every compaction over the vendor's cap;
- with any UA, once the fitting tries took past keepHeldAfter (3s: a 40
  MB upload asked four times, a slow link, -race on CI) keepAlive sent a
  200 and a comment first, and the 413 after it came the same way.

keptAlive.whole (set from wantsWhole) now gets neither a keepalive nor
the in-stream 413. Codex's own turns are unchanged.

9a51d644d (the 4-minute summary limit) is not the cause: the 502 comes
from the status, not the deadline.

Run at this head (mote, mote-run):
- go test -count=3 -run 'TestCompactionOverByteCap' ./internal/gateway ok
- the compaction/keepalive tests -count=2 ok (225s); -race of
  TestCompactionOverByteCap* ok (121s)
- gofmt -l clean

Broken by hand: on the old code TestCompactionOverByteCapSlowFitting
failed 3/3 (502 at ~1.8s); the codex-UA subtest of
TestCompactionOverByteCapEveryTime failed 3/3. Reverting the
compactsInStream half alone turns the codex subtests red; reverting the
keepAlive half alone turns the plain SlowFitting case red.

Not tried: a real Codex compaction over a vendor's byte cap with a real
account; the full suite runs once for this batch (recorded on the last
commit).
2026-11-05 03:07:43 +08:00
..