Skip to content

fix(sessions): preserve recently active sessions during pruning (salvage of #71043 by @Frowtek) - #72358

Merged
teknium1 merged 1 commit into
mainfrom
salvage/71043-prune-by-inactivity
Jul 27, 2026
Merged

teknium1 merged 1 commit into
mainfrom
salvage/71043-prune-by-inactivity

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

Summary

Auto-prune no longer deletes a recently-active conversation just because it was created long ago.

Root cause: prune_sessions / list_prune_candidates converted older_than_days to started_before on started_at. An ended, long-lived conversation used today but created >90d ago was deleted — and VACUUM makes recovery impractical.

Changes

  • hermes_state.py: retention age is now inactivityCOALESCE(MAX(messages.timestamp), started_at).
  • session_filters.py: new last_active_before/after; --older-than/--newer-than bound activity, --before/--after keep bounding start time.
  • CLI / dashboard / docs surface last_active (dashboard keeps oldest/newest_started_at for compat).

Note

Deliberate CLI semantics change: --older-than + --before become independent axes (was: tighter-bound-wins). Documented; test replaced accordingly. Conceptually overlaps #70429's indexed last_active column — coordinate if both land; prune runs at most once per interval so the correlated subquery cost is acceptable.

Validation

Real-SQLite regression tests across 5 files: 609 passed.

Salvage of #71043@Frowtek's commit cherry-picked with authorship preserved.

Infographic

Prune by inactivity

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery comp/cli CLI entry point, hermes_cli/, setup wizard comp/dashboard Web dashboard / control panel UI (dashboard/, landing) area/config Config system, migrations, profiles area/sessions Session lifecycle, resume, persistence, history P1 High — major feature broken, no workaround sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 27, 2026
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on d61560b

ℹ️ Info

Desktop E2E visual evidence · View test artifacts · View job

1 visual diff.

inline evidence upload failed.

Failed to upload diff-665a0833239e-onboarding-overlay-diff.png with gh image (exit code 1): Error uploading /home/runner/work/_temp/e2e-evidence/diff-665a0833239e-onboarding-overlay-diff.png: step 0 (get upload token): uploadToken not found on repo page — do you have write access to NousResearch/hermes-agent? (or, if NousResearch enforces SAML SSO, authorize at https://github.com/orgs/NousResearch/sso)

@teknium1
teknium1 merged commit a228b81 into main Jul 27, 2026
42 checks passed
@teknium1
teknium1 deleted the salvage/71043-prune-by-inactivity branch July 27, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles area/sessions Session lifecycle, resume, persistence, history comp/cli CLI entry point, hermes_cli/, setup wizard comp/dashboard Web dashboard / control panel UI (dashboard/, landing) comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants