fix(sandbox): support move-only apply patches - #4469
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3fd8f0f1a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| await self._session.mkdir(moved_destination.parent, parents=True, user=self._user) | ||
| data = io.StringIO(payload) if isinstance(payload, str) else io.BytesIO(payload) | ||
| await self._session.write(moved_destination, data, user=self._user) | ||
| await self._session.rm(destination, user=self._user) |
There was a problem hiding this comment.
Preserve filesystem metadata for move-only patches
When the source is executable and the destination does not already exist, implementing the advertised rename as read/write/remove copies only the payload and drops file metadata. For example, UnixLocalSandbox.write() creates the destination with open("wb") (src/agents/sandbox/sandboxes/unix_local.py:974-977), so moving a 0755 script typically produces a non-executable 0644 file and later sandbox commands can fail even though no content hunk was requested. Use a rename primitive or explicitly preserve the source metadata before removing it.
Useful? React with 👍 / 👎.
|
Closing this in favor of #4470 |
his pull request fixes grammar-constrained apply_patch updates that move a file without including content hunks.
It aligns the provider-facing Lark grammar with the plaintext parser, preserves the source payload byte-for-byte during move-only operations, and keeps the released programmatic editor behavior unchanged for updates with a missing diff.
Regression coverage includes the exposed grammar production, header-only update rejection, binary and mixed-newline payload preservation, and direct editor compatibility.
Resolves #4468