Skip to content

Feature: configurable inbound body limit - 922k context sessions 413 on remote compact (256 MiB hard-coded in request-decompress) #3573

Description

@nowhere1975

Area

Proxy and routing

What are you trying to accomplish?

With the GPT-5.6 1M (922k opt-in) context window configured, a long session eventually triggers Codex's automatic remote compaction. That compaction request replays the full conversation history to the compaction model, and once the session passes roughly 700-800k tokens the serialized request body exceeds the proxy's hard-coded 256 MiB inbound limit. The compact task then fails with:

Error running remote compact task: unexpected status 413 Payload Too Large: Decompressed request body exceeds 268435456 bytes, url: http://127.0.0.1:10100/v1/responses

Users on the large opt-in window cannot use automatic (or late manual) compaction at all, because the compaction request itself is what crosses the limit. I want the body limit to be configurable (or scaled with the model window) so large-context sessions can compact.

What prevents this today?

  • src/server/request-decompress.ts hard-codes MAX_DECOMPRESSED_BODY_BYTES = 256 * 1024 * 1024 for /v1/responses inbound bodies (readJsonRequestBody always uses it; there is no config lever).
  • A 922k-token session history serializes to well over 256 MiB of JSON, so remote compact (and any full-history request) returns 413 before parsing.
  • Manual /compact suffers the same 413 once the history is large enough - the user is stuck until they abandon the session.
  • The limit is independent of the configured context window: smaller windows (e.g. 272k) stay far below it, which is why this only bites the opt-in large-window setups.

What should OpenCodex do?

  1. Make the inbound decompressed-body limit configurable (e.g. a config key with a sensible default), and/or
  2. Derive it from the routed model's configured context window (limit >= window size serialized with headroom), so enabling the 1M opt-in does not silently break compaction, and/or
  3. At minimum, return a clearer error explaining that the session is too large to compact through the proxy (instead of an opaque 413), and suggest a smaller window or manual compaction earlier.

Example usage or interface

# config.json
"inboundRequestBodyLimitBytes": 536870912   # 512 MiB opt-in

# or per-model auto-scaling when the 922k window is enabled
"providers": { "openai": { "modelContextWindows": { "gpt-5.6-sol": 922000 } } }
# -> inbound limit scales to cover the window, compaction works

Alternatives or workarounds

  • Manually /compact before the session exceeds ~600k tokens (works, but easy to forget; automatic compaction still 413s if it fires late).
  • Revert to the 272k default window (compaction always safe, but the large-window capability is lost).

Additional context

Related: the 1M opt-in mechanism for gpt-5.6 (NATIVE_GPT56_MAX_INPUT_TOKENS / modelContextWindows), and #3196 which added an opt-in ceiling for oversized outbound passthrough bodies - this is the inbound analogue. Reproduced on 2.42.0.

Checks

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestproxyHTTP proxy, routing, reverse-proxy / management auth

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions