Summary
Zero currently persists session metadata and event logs to disk (~/.local/share/zero/sessions/ on Unix, %LOCALAPPDATA%\zero\sessions\ on Windows), but never prunes or deletes old session directories. Over extended usage, session logs and checkpoint blobs accumulate indefinitely without an automatic retention policy or CLI cleanup mechanism.
Motivation
While in-memory prompt compaction (internal/agent/compaction.go) and tool body pruning (internal/agent/prune.go) manage context token pressure, on-disk storage grows monotonically:
- Every session generates a separate directory containing
metadata.json, events.jsonl, and optional checkpoint blobs.
internal/sessions/store.go provides listing and appending, but no cleanup lifecycle or deletion API.
- Users currently have to manually inspect and delete old session directories.
Proposed Solution
- Configurable retention policy: Introduce configuration settings in
config.json (e.g. sessions.retention_days or sessions.max_count) to automatically prune stale, non-bookmarked session directories.
- CLI cleanup command: Add
zero sessions clean (or zero sessions prune --older-than <duration>) to allow users to trigger metadata sweeps manually.
- Blob & checkpoint garbage collection: Prune unreferenced rewind blobs when sessions are removed.
- Safety guards: Ensure active sessions (holding
session.lock) and explicitly saved/named sessions are protected from automated pruning.
Summary
Zero currently persists session metadata and event logs to disk (
~/.local/share/zero/sessions/on Unix,%LOCALAPPDATA%\zero\sessions\on Windows), but never prunes or deletes old session directories. Over extended usage, session logs and checkpoint blobs accumulate indefinitely without an automatic retention policy or CLI cleanup mechanism.Motivation
While in-memory prompt compaction (
internal/agent/compaction.go) and tool body pruning (internal/agent/prune.go) manage context token pressure, on-disk storage grows monotonically:metadata.json,events.jsonl, and optional checkpoint blobs.internal/sessions/store.goprovides listing and appending, but no cleanup lifecycle or deletion API.Proposed Solution
config.json(e.g.sessions.retention_daysorsessions.max_count) to automatically prune stale, non-bookmarked session directories.zero sessions clean(orzero sessions prune --older-than <duration>) to allow users to trigger metadata sweeps manually.session.lock) and explicitly saved/named sessions are protected from automated pruning.