Files
magpie/docs
yetone 083a8a2d47 gateway: a failed Codex compaction says what failed, never "Unknown error" (outrageous_piglet)
outrageous_piglet on Discord (magpie 0.1.1575): Codex's compaction ended
"Error running remote compact task: unexpected status 502 Bad Gateway:
Unknown error". codex-rs says "Unknown error" of an error status whose
body is empty or whitespace (UnexpectedResponseError::display_body).

Every path a compaction reaches, probed with a fake upstream answering
502/500/503/405/501 with an empty body, an HTML page and {"error":{}}:
- a magpie model (codexCompact, through serve, every wire): always a
  message, but a bare "Fake: 502 Bad Gateway" that doesn't say it was
  the compaction or where it went;
- Codex's own model on /responses: an empty body was already said
  (#409), a web page relayed as its markup;
- Codex's own model on /responses/compact (and compactOn's account):
  relayed byte for byte, so an empty body reached Codex empty. This is
  the path that gives "Unknown error".

Now:
- codexUpstreamOn says an empty or web-page error on /responses/compact
  as on /responses (codexSaidNothing): the model, the status, who it went
  to (Codex's sign-in, its API key, or the magpie account), and the page's
  title. An error OpenAI says in JSON still goes as it came.
- codexCompact's relayed failure is said as the compaction's, with who
  answered it (compactFailed), keeping the vendor's code, param and
  Retry-After.
- 405 and 501 join 404 (lacksEndpoint): the summary is asked again as
  text, then made locally, so a provider without the endpoint still
  compacts.

The reporter's provider and model aren't known, and their URL is
/responses, where magpie at 0.1.1575 already says an empty body; the
only empty relay found is /responses/compact. A proxy between Codex and
magpie answering 502 itself would also read so; not ruled out.

Run: go test -tags nogui -run 'Compact|Codex|NotAnAPI|Empty'
./internal/gateway ok. New tests TestCodexOwnCompactFailureIsSaid,
TestCodexCompactFailureSaysCompaction and
TestCodexCompactNoEndpointCompactsLocally fail with codex_backend.go
reverted by hand; TestCodexOwnCompactErrorAsSaid guards the unchanged
JSON relay and passes on both.
Run at the pushed tree (on origin/main 88ac42843), go test -tags nogui
-count=1 -timeout 45m: internal/gateway ok 447s, internal/codexcat ok,
internal/gui ok, internal/agent/... ok; internal/provider crashes in
TestUnreadLoginsWriteErrorsKeepCredentials ("close of synctest channel
from outside bubble" in filememo.Forget), red the same alone on
origin/main 88ac42843, filed as #3632 with a patch there; with that
test skipped internal/provider ok 152s. gofmt -l clean; GOOS=linux go
vet -tags nogui ./... and GOOS=windows go vet ./... clean.
Not tried: a real Codex against a real failing upstream.
2026-10-26 17:19:00 +08:00
..