Skip to content

Session storage grows unboundedly — add opencode session prune command and auto-cleanup config #22110

Closed as not planned

Description

@vsixer

Problem

opencode stores all session history, messages, file parts, and diffs in ~/.local/share/opencode/storage/ with no automatic cleanup and no CLI command to reclaim disk space.
After ~5 months of regular use on a single project, my storage has grown to:

~/.local/share/opencode/
├── storage/
│   ├── message/          497 MB   (conversation messages)
│   ├── part/             966 MB   (30,122 files — file content snapshots)
│   ├── session_diff/     989 MB   (session state diffs)
│   └── session/          5.3 MB   (1,324 session index files)
└── tool-output/           52 MB   (Playwright, shell outputs)
Total: ~5.1 GB

Growth rate: ~500 MB/month. At this pace, it will reach 6+ GB within a year for a single project.

What I'd expect

1. CLI command: opencode session prune

# Dry run — show what would be deleted
opencode session prune --older-than 30d --dry-run
# Delete sessions older than 30 days and reclaim disk space
opencode session prune --older-than 30d
# Show current storage usage by category
opencode session stats

2. Config option for automatic cleanup

"session": {
  "retention_days": 30,  // auto-prune sessions older than N days
  "max_storage_mb": 2048 // or cap by total size
}

3. What should be cleaned up

When a session is deleted, all associated data should be removed:

  • storage/session/{project_id}/ses_*.json
  • storage/message/ entries linked to that session
  • storage/part/ entries linked to those messages (the biggest contributor at ~1 GB)
  • storage/session_diff/ses_*.json
  • tool-output/ entries linked to that session

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    perfIndicates a performance issue or need for optimization
    on Apr 12, 2026
  2. github-actions commented on Apr 12, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Feature requests must use the [FEATURE]: prefix in the title (e.g. [FEATURE]: Session storage grows unboundedly...)
    • The feature request template requires checking the verification checkbox confirming the feature hasn't been suggested before

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


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

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. github-actions commented on Apr 12, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

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)perfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions