#12806: feat(memory): add continuity rollup system for session persistence
docs
cli
agents
stale
Cluster:
Memory Management Enhancements
## 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
#8919: Pr/memory flush improvements
by shortbus · 2026-02-04
76.2%
#19341: Mind Memory Fork
by juliopx · 2026-02-17
75.6%
#9012: fix(memory): resilient flush for large sessions [AI-assisted]
by cheenu1092-oss · 2026-02-04
75.6%
#10591: feat(hooks): add session-start-memory bundled hook
by morningstar-daemon · 2026-02-06
75.3%
#14576: Fix/memory loss bugs
by ENCHIGO · 2026-02-12
75.2%
#13889: feat: Slack channel cache, session cost alerts & checkpoint/recover...
by trevorgordon981 · 2026-02-11
74.8%
#22220: feat(bootstrap): cache session's bootstrap files so we don't invali...
by anisoptera · 2026-02-20
74.6%
#7196: docs: Agent continuity - the 'stranger problem' and lighter approach
by sincere-arjun · 2026-02-02
74.6%
#6060: feat(onboarding): add Memory Optimization step to onboarding wizard
by GodsBoy · 2026-02-01
74.6%
#2884: fix: Create memory directory and symlink identity files during work...
by webdevtodayjason · 2026-01-27
74.5%