easyrev's vendor refuses a turn past the model's window with a 400
whose message is "The message is longer than the model context length"
(code context_length_exceeded). tooLongRe knew Together's wording, with
"model's", only, so the refusal wasn't read as an overflow: Codex got
the 400 JSON whole, which it takes for an invalid request and shows raw,
instead of response.failed context_length_exceeded in its stream, which
it compacts on. The 's is optional now.
Not changed: a vendor whose only overflow signal is the code field, with
words tooLongRe doesn't know, still isn't read as one; the words passed
to tooLong are the vendor's message, not its code.
Run (mote): go test -tags nogui -run
'TestEveryVendorsOverflow|TestCodexByteCapBeforeStreamCompacts'
./internal/gateway/ ok; the whole internal/gateway package ok (926s) on these changes over 4e7661adc, the targeted tests again at this head, rebased onto b712adb84; go vet -tags nogui ./internal/gateway/ and
gofmt -l clean.
Broken by hand: gateway.go put back with the tests kept, both fail
("Codex wasn't told in its stream to compact: 400 application/json
…context_length_exceeded…" and "…isn't taken for a conversation too
long").
Not tried: a real Codex CLI against the reporter's vendor.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
A Codex user on a DeepSeek model kept getting "stream disconnected
before completion: 1017dp: 413 Request Entity Too Large: a web page,
not an API reply ... (request_too_large)" with "reconnecting 5/5".
The big body took the vendor past keepHeldAfter, so Codex's stream
had begun, and streamError sent response.failed with code
server_error. Codex (codex-api sse/responses_error.rs) reads any code
it doesn't know as Retryable, so it sent the same body five more
times. Each was refused the same way, and nothing compacted.
context_length_exceeded is the one code Codex stops on: it marks the
window full and compacts, and core compact.rs trims the oldest items
for as long as the compaction is refused too.
- streamError: a 413 on the Responses shape is code
context_length_exceeded, for every Responses client. The text still
says request_too_large for pi.
- failTo: Codex reads a 413 told by HTTP status as UnexpectedStatus,
and a 400 context_length_exceeded as InvalidRequest
(api_bridge.rs). Neither compacts. So when Codex (fromCodex, or
Claude Code's Codex plugin) asked for a stream, a byte cap or an
overflow goes to it in a stream even before one began
(keptAlive.compactsInStream). A vendor's own overflow, released
until now, goes this way too. Other clients keep the status they got
before.
- Nothing changes for resting: a 413 still rests nobody, and a group
still tries the next member first.
Tests: codex_byte_cap_test.go. It replays the reporter's nginx page
mid-stream and before the stream, plus a vendor overflow 400, and
checks a non-Codex client keeps its 413. Red on the old code:
TestCodexByteCapInStreamCompacts got "server_error" (the reporter's
exact text), and both TestCodexByteCapBeforeStreamCompacts cases got
a 413 or 400 JSON. TestStreamErrorByteCapInEveryShape now expects
context_length_exceeded for Responses.
Run on mote (mote-run, this tree): go test ./internal/gateway on the
byte-cap, stream-error, overflow, compact and Codex tests: ok. GOOS=linux
and GOOS=windows go vet ./internal/gateway: ok. gofmt -l: clean.
Full suite: mote-run go test -timeout 45m ./... at fb29cd30f plus this
change (before the gateway-routing.md paragraph, docs only): 82 packages
ok; internal/gui red in two tests this change doesn't reach, both filed:
TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll not kept, #4514) and
TestMainWindowCorners/macOS_26_SDK (macOS 27 toolbar, #3949).
Not tried: a real Codex against a real 413 vendor. Codex's handling
was read from openai/codex main, not run. DeepSeek documents no
request-body byte limit, and whether 1017dp is DeepSeek's own API or
a relay in front of it is unknown.