Files
magpie/docs
yetone 97f264c7fb gateway: a 413 on the OpenAI routes says request_too_large, so pi compacts (@wilsonxuuuu on X)
@wilsonxuuuu's pi, on gpt-6.1 through magpie, stopped on
"magpie API error (413): {...,"type":"api_error"}" at 114k of a 1M
window and never auto-compacted. The vendor's 413 was a body byte cap.
pi's overflow table (pi-ai utils/overflow.ts) knows a byte cap only as
request_too_large, Anthropic's type, which magpie already gave on the
Anthropic route but not on chat/responses. writeErrorSaid now types
every 413 request_too_large (Gemini keeps its own status shape). The
status stays 413 and the byte-limit hint stays; it is not turned into
context_length_exceeded, so Codex and Claude Code read it as before
(Codex reads code, not type). pi compacts once and retries once
(_overflowRecoveryAttempted), so a body that is still too big after
compacting stops instead of looping.

Run:
- pi 1.1.0's own isContextOverflow on the reporter's body: api_error
  false, request_too_large true.
- TestPayloadTooLargeSaysRequestTooLargeToPi (an nginx 413 page from a
  chat upstream) and the new Chat/Responses rows of
  TestBodyRejectionErrorShapes fail with the gateway.go change reverted
  by hand, pass with it.
- go test -tags nogui -count=1 -timeout 45m ./... under a sandbox HOME:
  every package ok. gofmt clean; GOOS=linux and windows go vet of
  internal/gateway clean.
Not tried: a real pi session hitting a real vendor 413.
2026-10-16 06:09:50 +08:00
..