mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-06 08:06:50 +00:00
The ChatGPT Codex backend announces the largest WebSocket message it accepts in x-codex-websocket-max-message-bytes (currently 128 MiB). The gateway ignored it and bridged every session whose first message reached a fixed 15 MiB to HTTP, after which each turn replays the full input to the upstream instead of continuing incrementally over WebSocket. Record the announced limit per account on every successful upstream handshake and derive the bridge threshold from it, minus a margin for fields the gateway adds. http_bridge_threshold_bytes now defaults to 0 (follow the upstream); an explicit value caps the upstream limit, and the 15 MiB default still applies until a limit is known. Also announce the gateway's client read limit in the same header on the client handshake, so Codex clients stop before uploading a message the gateway would reject.