Skip to content

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

Closed

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

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 18, 2026
  2. github-actions commented on Mar 18, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  3. ihubanov commented on Mar 18, 2026

    @ihubanov
    Author

    Thanks for flagging these — #8887 and #3182 are definitely the same root cause.

    #8887 proposes respecting the existing watcher.ignore config in the snapshot module, which makes sense as a proactive fix. Our PR (#18069) takes a complementary approach with a runtime safety net: a 15-second timeout on git add . that triggers automatic exclude generation only when the operation is actually slow. This handles cases where users haven't configured watcher.ignore (which seems common given #3182).

    Ideally both approaches could be combined — respect watcher.ignore upfront (as #8887 suggests) AND have a timeout fallback for unconfigured workspaces. Happy to update the PR to incorporate the watcher.ignore integration from #8887 if the maintainers prefer a combined fix.

    Linking: this also fixes #8887 and #3182.

  4. 00sapo commented on Mar 18, 2026

    @00sapo

    Any temporary workaround?

  5. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    This should be fixed by commit 0a80ef4 which adds a 2MB file size limit for snapshotting. Large files are now skipped during git add operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions