Repository navigation
Description
Client or integration
Codex App (desktop) pointed at a local OpenCodex endpoint
Area
Proxy and routing
Summary
When an upstream returns HTTP 413, OpenCodex normally converts it into a terminating context_length_exceeded event so the client compacts and retries with a smaller request. That conversion is not applied on the web-search sidecar path (and the images/video sidecar path). The 413 leaks out as a generic upstream error, and Codex just resends the same oversized payload until it gives up.
Reproduction
- Run OpenCodex with the web-search sidecar enabled and a Codex client on the local endpoint.
- Send a turn large enough for the upstream to reject the body. Here: two inline screenshots (~2.8 MB as base64), and the upstream gateway answered 413 with a plain-text body.
- The client reports the error below and retries four times with the identical payload. No compaction is triggered and nothing in the message tells the client what to shrink.
Version
Affects 2.81.0. I unpacked the published 2.88.0 tarball and the same two throw sites are still there, so it is not fixed on latest.
Operating system
Linux
Provider and model
An OpenAI-compatible chat upstream behind a relay (openai-chat adapter), routed to a non-OpenAI model. The bug is not provider-specific, but a plain-text 413 body matters; see the root cause below.
Logs or error output
unexpected status 413 Payload Too Large: Provider error 413, url: http://127.0.0.1:10100/v1/responses
Four attempts, roughly 125 s apart, each lasting ~125 s before failing, always the same body. The upstream itself returned Request body exceeds the 8 MiB limit., but none of that text reaches the client.
Root cause
- The mapping already exists:
src/server/responses/context-overflow.tsturns an upstream 413 into a terminating event withcode: context_length_exceeded, explicitly so the client compacts instead of resending. - It is only wired into
adapter-dispatch.ts:1550,passthrough-delivery.ts:574,core-combo.ts:1047and:1191, plus the local inbound rejection atrequest-prepare.ts:1335. - The sidecar bypasses it.
src/web-search/loop.ts:621and:634thrownew LoopError(prepared.response.status, "Provider error " + status + suffix), andjsonError()(loop.ts:253) returns it as{error:{message, type:"upstream_error", code:null}}.src/images/loop.ts:711and:724are the same shape. - Nothing re-checks on the way out: the
runWithWebSearch(...)result atsidecar-execution.ts:545is returned directly fromcore.ts:137. suffixis only appended whenformatErrorBodycan extract text from the body. A plain-text 413 parses to an empty string by design, which is why the message is the bareProvider error 413with no size hint.- In
2.88.0the same throw sites are atsrc/web-search/loop.ts:494and:507, andsrc/images/loop.ts:766and:779, with no context-overflow handling added.
Suggested fix
Reuse context-overflow.ts on the sidecar error path, ideally once at the sidecar-execution boundary so both the web-search and images loops are covered, and let a 413 from either sidecar terminate as context_length_exceeded the way the main path already does.
Relation to #4112
Not the same path. #4112 was about the non-streaming branch in adapter-dispatch, and that mapping works on this version. This report is only about the sidecar bypass.
Screenshots and supporting files
None. Everything here is redacted.
Redacted configuration
Web-search sidecar enabled, upstream is an OpenAI-compatible relay. Endpoint host, account details and model routing have been removed.
Checks
- I searched existing issues for
413,context_length_exceededandsidecar, and found nothing covering this path. - I confirmed the behaviour on the latest published version, not just my installed one.
Activity
Ingwannu commentedon Oct 19, 2026
Confirmed the missing sidecar path on current dev d11f067: the fetch search/image loops turned an upstream 413 into a generic LoopError rather than the shared context-overflow envelope. Eight focused plain-text/JSON and streaming/buffered cases failed before the fix.
A minimal local patch now reuses the existing context-overflow event/response helper, preserves HTTP 413 inside Combo until its outer client boundary, and keeps the existing named free-tier-cap hop. The final focused run is 114 passed / 0 failed across five files, including Responses-entry search/Combo controls, image-loop coverage, unchanged 400/429 behavior and a synthetic-local refusal control; layout/file-size/import-cycle checks (11 tests) and structure SSOT also pass. These are isolated Linux/Bun 1.4.3 fixtures, not real provider or video-generation acceptance.
Root typecheck exceeded this host's fixed 300-second validation envelope; no pass is claimed. The patch remains a local review artifact while publication/required hosted validation is pending. No upstream PR has been published for this patch, no fixing dev commit or release is claimed, and this issue stays open. No installed proxy or service was changed.
github-actions commentedon Oct 19, 2026
Automated translation bookkeeping — detected language: English.
fix(sidecar): classify overflow where the loop still has the evidence
fix(sidecar): keep a non-overflow verdict typed through the SSE bridge
fix(sidecar): map provider input overflow to context_length_exceeded (#…
lidge-jun commentedon Oct 19, 2026
Fixed by #7352 (merged into
devas 0a995db). Sidecar (web search / images) provider overflows, including bare HTTP 413, now map tocontext_length_exceededlike the main path. Ships in the next release.