fix(sessions): delete on-disk transcript files during prune and delete#6613
Closed
SeeYangZhi wants to merge 1 commit into
Closed
fix(sessions): delete on-disk transcript files during prune and delete#6613SeeYangZhi wants to merge 1 commit into
SeeYangZhi wants to merge 1 commit into
Conversation
NousResearch#3015) `delete_session()` and `prune_sessions()` only removed SQLite records, leaving .json/.jsonl transcript files on disk forever. Over time this causes unbounded disk growth (~27MB/day observed). Changes: - Add `_remove_session_files()` static helper that cleans up `{session_id}.json`, `.jsonl`, and `request_dump_{session_id}_*.json` - `delete_session()` accepts optional `sessions_dir` param and removes files for the deleted session and its children - `prune_sessions()` accepts optional `sessions_dir` param and removes files for all pruned sessions after the DB transaction - Wire up CLI `hermes sessions delete` and `hermes sessions prune` to pass `sessions_dir` - File cleanup is best-effort (OSError silenced) so DB operations are never blocked by filesystem issues - Fully backward-compatible: `sessions_dir=None` (default) preserves existing behavior
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3015
Problem
delete_session()andprune_sessions()only remove SQLite records, leaving.json/.jsonltranscript files in~/.hermes/sessions/forever.session_searchreads from SQLite FTS5 (state.db), not from these files, so they are dead weight after session end.Observed: 340 files, 82MB in 3 days (~27MB/day, ~10GB/year).
Changes
hermes_state.py:_remove_session_files()static helper — cleans up{session_id}.json,.jsonl, andrequest_dump_{session_id}_*.jsondelete_session(sessions_dir=)— removes transcript files for the session and its childrenprune_sessions(sessions_dir=)— removes transcript files for all pruned sessions after the DB transactionhermes_cli/main.py:hermes sessions deletenow passessessions_dirhermes sessions prunenow passessessions_dirDesign Decisions
sessions_dirparam (defaultNone) — fully backward-compatible. Callers that don't pass it get existing behavior (SQLite-only cleanup). This avoids breaking any internal callers.OSErrorsilenced so DB operations are never blocked by filesystem issuesprune_sessions()— session IDs are collected during the transaction, files deleted after commitWhat This Does NOT Change
/resumebehavior (resumed sessions keep their files)