Skip to content

Snapshot git add runs indefinitely on worktrees with large non-code files #18072

@ihubanov

Description

@ihubanov

Description

When opencode is used in a workspace that contains large non-code files (media files, datasets, ML models, etc.), the snapshot system's git add . can run indefinitely, consuming excessive CPU and memory.

The snapshot system maintains a separate git repo to track worktree state. It runs git add . against the full worktree on every agentic step (via the add effect in snapshot/index.ts). When the worktree contains large directories with binary/media files, this operation never completes in a reasonable time.

Steps to reproduce

  1. Open opencode in a workspace containing a large directory (e.g. 500MB+ of media files, datasets, or ML model weights)
  2. Start a session and interact with the assistant
  3. Observe git add . and git pack-objects processes consuming high CPU/memory indefinitely

Observed behavior

  • git add . ran for 3+ hours at ~90% CPU
  • The subsequent hourly git gc (snapshot cleanup) consumed ~3.7GB of RAM trying to repack the bloated snapshot repo
  • The system became sluggish and required manual process killing

Expected behavior

The snapshot system should handle large worktrees gracefully — either by timing out and excluding large/binary files, or by respecting size limits.

Environment

  • OS: Linux (Ubuntu)
  • opencode version: v1.2.27

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions