Skip to content

fix(sandbox): support move-only apply patches - #4469

Closed
seratch wants to merge 1 commit into
mainfrom
fix/apply-patch-move-only
Closed

fix(sandbox): support move-only apply patches#4469
seratch wants to merge 1 commit into
mainfrom
fix/apply-patch-move-only

Conversation

@seratch

@seratch seratch commented Aug 17, 2026

Copy link
Copy Markdown
Member

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

@seratch seratch added this to the 0.21.x milestone Aug 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +152 to +155
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@seratch seratch removed this from the 0.21.x milestone Aug 17, 2026
@seratch

seratch commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

Closing this in favor of #4470

@seratch seratch closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apply_patch grammar accepts empty updates that the runtime parser rejects

1 participant