Skip to content

Snapshot feature consumes excessive disk space (170GB+ in my case) #17753

Closed

Description

@JinHanAI

Description

The snapshot feature accumulated 170GB of disk space on my Mac. The git objects in ~/.local/share/opencode/snapshot/ grew unchecked over time.

Root Cause

Looking at packages/opencode/src/snapshot/index.ts:

  • The entire worktree is tracked via git
  • Cleanup only runs hourly via scheduler with git gc --prune=7.days
  • No disk space warning when snapshot grows large
  • Temporary pack files (tmp_pack_*) may not be cleaned up if opencode crashes

Steps to Reproduce

  1. Use opencode regularly over time
  2. Check ~/.local/share/opencode/snapshot/ directory size
  3. In my case: du -sh ~/.local/share/opencode/snapshot/ showed 170GB

Workaround

  1. Delete the snapshot directory: rm -rf ~/.local/share/opencode/snapshot/
  2. Disable snapshot in config: {"snapshot": false}

Suggested Fix

Add a disk space warning when the snapshot directory exceeds a threshold (e.g., 1GB). This would alert users before the problem gets out of hand.

I'm willing to submit a PR for this if the maintainers agree with the approach.

Environment

  • OS: macOS Sequoia 15.3
  • OpenCode: latest (via brew)

Activity

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

    @github-actions
    Contributor

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

    If your issue is the same, please consider adding a "+1" or additional context to one of those existing issues rather than opening a new one.

  3. added a commit that references this issue on Mar 16, 2026
    664eaf2
  4. JinHanAI commented on Mar 16, 2026

    @JinHanAI
    Author

    I've submitted PR #17757 to address this issue.

  5. JinHanAI commented on Mar 16, 2026

    @JinHanAI
    Author

    Reopened as PR #17811 with proper template format.

  6. added a commit that references this issue on Mar 17, 2026
    c53aeb9
  7. Znerual commented on Mar 23, 2026

    @Znerual

    Same issue here, I would like to have a better fix than just a warning that it eats so much storage. What information can I provide to aid with the solution? I assume its a bug, there is no reason to store GBs of information for code changes. I had it in previous versions of opencode, it would be great if there was a cleanup feature to delete specific snapshot content for older sessions.

  8. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    This should be fixed by commit 0a80ef4 which adds a 2MB file size limit for snapshotting. Files over 2MB are now excluded from git snapshots, reducing overall snapshot storage consumption.

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