mirror of
https://github.com/openai/codex.git
synced 2026-09-04 15:08:45 +00:00
## Why Remote MCP stdio buffers executor-provided stdout until a JSON-RPC line completes and stderr until a diagnostic line completes. A malicious or broken executor can keep sending chunks without a newline, making orchestrator memory grow without bound. Executor event boundaries are arbitrary, so a valid message before an oversized line must not be lost merely because both arrived in one event. ## What changed - Limit one stdout JSON-RPC line to 8 MiB. - Limit one stderr diagnostic line to 1 MiB. - Check each logical line before copying its bytes into the retained buffer. - Preserve complete stdout messages that precede an oversized line and deliver them before closing the stream. - Close the MCP transport on overflow; existing transport cleanup terminates the executor-managed process. - Preserve multiple lines per chunk, CRLF framing, and final unterminated messages at EOF. - Box the pending stdio transport so the added framing state does not inflate every `ClientState` value. - Add regression coverage for cross-chunk overflow, bounded lines in a larger chunk, and a valid prefix before an oversized line. ## Scope This bounds pre-newline buffering for executor-backed MCP stdio only. It does not change local stdio framing or address memory amplification while parsing a complete JSON message.