← Back to PRs

#12806: feat(memory): add continuity rollup system for session persistence

by koala73 open 2026-02-09 18:20 View on GitHub →
docs cli agents stale
## Summary Implements a memory distillation and injection system that maintains context across sessions. This addresses the need for **compaction continuity** where important decisions, todos, and context are preserved even after session compaction. ## Core Features ### 1. Continuity Rollup Injector - Automatically injects `ROLLUP.md` into non-group sessions - Rollup is inserted before `MEMORY.md` in bootstrap files - **Security**: Skipped for group/channel sessions (privacy protection) - **Minimal context**: Skipped for subagent sessions ### 2. CLI Commands (`openclaw memory rollup`) | Command | Description | |---------|-------------| | `install` | Creates hourly cron job to distill memory | | `remove` | Removes the distiller cron job | | `run` | Triggers distillation immediately | | `show` | Displays current rollup content | | `path` | Prints rollup file location | | `clear` | Deletes rollup file | ### 3. Distiller Agent The cron job runs an isolated agent that: 1. Uses `memory_search` to find recent decisions, todos, context 2. Synthesizes into a structured rollup with sections: - **Active Context**: Current work focus - **Recent Decisions**: Key choices with dates - **Pending Actions**: Open items 3. Writes to `~/.openclaw/agents/<agent>/continuity/ROLLUP.md` ## Usage ```bash # Install the hourly distiller openclaw memory rollup install # Custom interval openclaw memory rollup install --every 30m # Run once immediately openclaw memory rollup run # View current rollup openclaw memory rollup show # Remove the cron job openclaw memory rollup remove ``` ## Files Changed - `src/continuity/rollup.ts`: Path resolution for rollup files - `src/agents/bootstrap-files.ts`: Rollup injection logic - `src/agents/workspace.ts`: Added `ROLLUP.md` to bootstrap file types - `src/sessions/session-key-utils.ts`: Added `isGroupChannelSessionKey()` - `src/routing/session-key.ts`: Export new utility - `src/cli/memory-cli.ts`: Rollup subcommands - `docs/cli/memory.md`: Updated documentation ## Tests - Added tests for `isGroupChannelSessionKey()` (7 test cases) - Added tests for rollup injection: - Injects for direct/DM sessions ✓ - Skips for group sessions ✓ - Skips for subagent sessions ✓ ## Security Considerations - Rollup content is **never** exposed to group chats or channels - Rollup is stored in the state directory, not the workspace (avoids accidental git commits) - Distiller runs in isolated session with delivery mode `none` (silent operation) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a "continuity rollup" system intended to preserve key context across sessions by periodically distilling memory into a `ROLLUP.md` file (stored under the state directory) and injecting that file into the bootstrap context for applicable sessions. Key changes include: a new rollup path resolver (`src/continuity/rollup.ts`), rollup injection into bootstrap file resolution (`src/agents/bootstrap-files.ts`), adding `ROLLUP.md` to the workspace bootstrap file types, a new `isGroupChannelSessionKey()` session-key helper exported via routing, and a new `openclaw memory rollup` CLI surface that manages a cron-based distiller job plus local show/path/clear operations. Docs and tests were added/updated to cover the new behaviors. <h3>Confidence Score: 3/5</h3> - This PR is moderately safe to merge but has a few correctness issues that will affect multi-agent cron behavior and rollup generation/injection semantics. - Core idea and tests are present, but the cron job is identified only by a global name (causing collisions across agents), the distiller prompt likely generates rollups that get treated as front matter, and rollup injection currently doesn’t explicitly exclude subagent sessions at the point of injection. - src/cli/memory-cli.ts, src/agents/bootstrap-files.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs