anomalyco / anomalyco/opencode

apply_patch embeds deleted binary contents in session metadata

Open
#41,733 1 comment 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Aug 11, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
Avg merge
7h 2m
Merged PRs (30d)
384

Description

Description

Deleting a binary or very large file with apply_patch decodes the entire file as UTF-8 and generates a full unified diff. The diff is stored in both the tool result and per-file metadata, so deleting one large archive can add hundreds of megabytes to opencode.db and terminate the Desktop sidecar.

The delete operation only needs the path; binary and oversized file contents should be omitted from metadata.

Plugins

None required.

OpenCode version

1.18.16

Steps to reproduce
  1. Create a large ZIP file in a project.
  2. Delete it through an apply_patch *** Delete File operation.
  3. Inspect the resulting tool part/event in opencode.db.
  4. Observe that the deleted bytes are decoded into a full diff in both metadata.diff and metadata.files[].patch.

With a roughly 295 MB archive, the stored tool part and event were about 619 MB each and the Desktop sidecar exited immediately afterward.

Screenshot and/or share link

Not included because the affected session contains local file metadata. A focused regression test is available with the fix.

Operating System

Windows 11 x64

Terminal

OpenCode Desktop

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.