Repository navigation
fix(agent): make pair-mode edits work on the first try - #408
Merged
Merged
Conversation
Codex tells the model its sandbox is read-only, and Red's instructions never said that only covers the shell and patch tools it lacks, so the agent often refused to edit (always when the buffer had unsaved changes). Say that apply_edits and write_file are the supported way to change files. Disk revision tokens used bit 63, but Codex runs tool calls through JavaScript, which rounds integers above 2^53. Every first edit of an unopened file came back as a stale revision. Keep tokens in 53 bits.
Contributor
Author
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
An end-to-end evaluation of pair mode against a real Codex app-server (38 threads, 63 turns) found two bugs that made agent edits fail even though nothing was wrong with the request.
Why
The agent refused to edit. Codex tells the model that its sandbox is read-only. Red's instructions said "You have no shell or native patch tool" but never said that the read-only sandbox only covers those missing tools. The model often concluded it could not change files and pasted code for the user to apply instead. On
mainit refused in 1 of 6 fresh sessions with a clean buffer, and in 5 of 5 when the target buffer had unsaved changes. Once a session refused, it kept refusing.The first edit of an unopened file always failed as stale.
read_fileon a file without a buffer returns a disk revision token, and #406 marked those tokens with bit 63. Codex runs tool calls through a JavaScript runner, which rounds integers above 2^53, so15400823821884425090came back as15400823821884424000andapply_editsrejected it withstale_revision. The agent recovered by re-reading, at the cost of one wasted round-trip for every file it touched.What changed
src/codex/mod.rs:INSTRUCTIONSnow says the read-only sandbox applies only to the missing shell and patch tools, and thatapply_editsandwrite_fileare the supported way to change files.src/editor.rs: disk tokens use bit 52 as their marker and a 52-bit hash, so they are exact JavaScript integers. Buffer revisions are edit counters and never reach that range.Measured with the same prompt ("Add a doc comment to the summarize function in src/report.rs. Change nothing else.") in fresh sessions:
mainHow to Test
Space Aand ask "Add a doc comment to the main function. Change nothing else."apply_editsinstead of replying that the session is read-only.apply_edits. In the newest~/.codex/sessions/**/rollout-*.jsonl, the revision passed toapply_editsequals the oneread_filereturned, and there is nostale_revisionresult.Targeted tests:
cargo test --lib agent_disk_revisions_survive_a_javascript_number_round_tripcargo test --lib agent_reads_of_unopened_files_leave_buffers_alone_and_guard_later_writes