feat: session auto-rotation with optional summary generation#43
Open
artemasmith wants to merge 2 commits intomoazbuilds:masterfrom
Open
feat: session auto-rotation with optional summary generation#43artemasmith wants to merge 2 commits intomoazbuilds:masterfrom
artemasmith wants to merge 2 commits intomoazbuilds:masterfrom
Conversation
Sessions degrade over time as context fills up. This adds automatic rotation based on message count (default 50) and session age (default 24h). When summaryPath is configured, generates a markdown summary of the expiring session via `claude --resume` before rotating, and loads the latest summary into the bootstrap prompt of the new session. New config section in settings.json: session.autoRotate (bool, default true) session.maxMessages (number, default 50) session.maxAgeHours (number, default 24) session.summaryPath (string, default "" = no summaries) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fenrur
added a commit
to Fenrur/claudeclaw
that referenced
this pull request
Mar 17, 2026
…builds#43) - Auto-rotate sessions based on message count and age - Generate session summaries before rotation - SessionConfig with autoRotate, maxMessages, maxAgeHours, summaryPath - peekSession for pre-rotation inspection Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
sounds awesome ... like a great idea ... how does the dev_process work, you create changes on a branch and then moaz is reviewing them for the next release if time allows? |
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.
Problem
Long-running ClaudeClaw sessions degrade as context fills up — Claude starts contradicting itself and producing lower quality responses. The built-in compression only kicks in near the context limit, not preventing gradual degradation.
Solution
Automatic session rotation based on configurable thresholds:
When
summaryPathis configured, the expiring session generates a markdown summary before rotating. The latest summary is loaded into the bootstrap prompt of the new session, preserving context continuity.Changes
src/sessions.ts— addedmessageCounttoGlobalSession, incremented on eachgetSession()src/config.ts— addedSessionConfiginterface and parsingsrc/rotation.ts— new file:needsRotation(),rotateSession(),loadLatestSummary()src/runner.ts— rotation check beforeexecClaude(), summary loading inbootstrap()prompts/SUMMARY.md— prompt template for summary generationConfiguration
New
sessionsection insettings.json:{ "session": { "autoRotate": true, "maxMessages": 50, "maxAgeHours": 24, "summaryPath": "/path/to/summaries" } }All fields are optional with sensible defaults. When
summaryPathis empty (default), rotation happens without summary generation.Backward Compatibility
messageCountdefaults to0for existing sessions via|| 0fallbackautoRotatedefaults totruebut does nothing without the config sectionsessionconfig is absent