[codex] Add streaming file APIs#27190
Draft
nornagon-openai wants to merge 8 commits into
Draft
Conversation
This was referenced Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The existing
fs/readFileandfs/writeFilemethods materialize an entire file in one request. That is unsuitable for large files and remote app-server clients. Pull-based chunks provide bounded memory use, natural backpressure, cancellation between requests, and optional client-side pipelining without adding a separate push protocol.Streaming writes should retain the behavior of the existing
fs/writeFileAPI. Replacing the destination with a temporary file would change file identity, break hardlinks, discard executable bits and extended metadata, and potentially weaken custom Windows ACLs. The streamed API therefore opens the destination with ordinary create-or-truncate semantics.A local benchmark measured strict pull at roughly 270 MiB/s and two-request pipelined pull at roughly 367 MiB/s, matching the temporary push implementation. The push API was therefore omitted.
What changed
Add connection-scoped, client-supplied file handles to app-server v2 and exec-server:
fs/readFile/open,read,stat, andcloseprovide bounded positional reads.fs/writeFile/open,write, andcloseprovide bounded sequential writes.Droprequests.eofresult.Opening a write handle creates or truncates the destination immediately. Completed chunks are visible immediately. Cancellation, disconnection, or an I/O error can leave a partially written file, matching ordinary truncate-and-write behavior. Existing destination identity and metadata are preserved.
Validation
just test -p codex-app-server-protocol(227 tests)just test -p codex-exec-server(204 tests)just test -p codex-app-server(833 tests, 1 skipped)just fix -p codex-file-system -p codex-exec-server -p codex-app-server-protocol -p codex-app-server