Exempt starred sessions from auto-archival (keep-alive)#193
Merged
Conversation
Extend the existing per-session `starred` flag so a starred session is never auto-closed. It already survived content pruning; now it is also exempt from all session auto-archival: - db (db/sessions.py): skip starred rows in the idle-cutoff, age-backstop, and overflow-eviction queries; count_active_sessions gains an opt-in exclude_starred so starred sessions are off-budget for max_sessions (neither counted toward the cap nor evicted). - sessions (agent/sessions.py): SessionManager.set_starred / toggle_starred; run_cleanup documents the exemption. - telegram (channels/telegram.py, router.py): a per-session star toggle in the /sessions list, a marker on switch buttons, and /star, /unstar commands. - config + docs/config.md: document the exemption. - tests: cover all three cleanup paths and the telegram toggle. The web star button already exists and inherits the new behavior. Re-lands the change from #189, which merged into its stacked scaffold base branch rather than main; this is the same feature cleanly rebased onto main. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
pufit
approved these changes
Jul 21, 2026
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.
What
Extend the existing per-session star flag so a starred session is never auto-closed.
starredalready means "this session is important" — the retention pruner skips starred sessions. This adds the natural second half: a starred session is exempt from all auto-archival (the interactive idle cutoff, the 30-day backstop, and themax_sessionsoverflow eviction) and is off-budget formax_sessions(neither counted toward the cap nor evicted), until explicitly unstarred/archived/deleted.Changes
db/sessions.py) —AND starred = 0in the three cleanup queries (get_stale_interactive_sessions,get_stale_sessions,get_oldest_sessions);count_active_sessionsgains an opt-inexclude_starred.agent/sessions.py) —SessionManager.set_starred/toggle_starred; exemption documented onrun_cleanup.channels/telegram.py,router.py) — a per-session ⭐/☆ toggle in/sessions, a ⭐ marker on switch buttons, and/star·/unstar.docs/config.md— document the exemption.The web star button (
SessionSidebar) already exists and inherits the new behavior.max_sessions: starred are off-budgetStarred sessions are not counted toward the cap and never evicted; the cap governs only non-starred sessions. Trade-off: total sessions can grow unbounded via starring — intended (the limit is for ordinary sessions).
History
Re-lands #189, which — after its dependencies #182/#184 merged — was merged into its stacked scaffold base branch rather than
main, so the feature never reachedmain. This is the identical change, cleanly rebased onto currentmainas a single commit.Testing
pytest tests/test_sessions.py tests/test_telegram_sessions.py→ 82 passed.🤖 Generated with Claude Code