#8903: fix: improve compaction summary instructions to preserve active work
agents
stale
Cluster:
Memory Compaction Improvements
## Problem
When compacting conversation history, the merge summaries instruction was:
```
Merge these partial summaries into a single cohesive summary.
Preserve decisions, TODOs, open questions, and any constraints.
```
This misses the most critical context for agent continuity:
- What the agent was actively working on
- Batch operation progress (e.g., '5/17 items done')
- The most recent user request
Result: Post-compaction amnesia where the agent knows facts but forgets what it was doing.
## Solution
Expanded instructions with explicit priorities:
```
MUST PRESERVE:
- Active tasks and their current status (in-progress, blocked, pending)
- Batch operation progress (e.g., '5/17 items completed')
- The last thing the user requested and what was being done about it
- Decisions made and their rationale
- TODOs, open questions, and constraints
- Any commitments or follow-ups promised
PRIORITIZE recent context over older history. The agent needs to know
what it was doing, not just what was discussed.
```
## Impact
- Better context preservation during compaction
- Reduced 'what was I doing?' moments
- Batch operations can continue after compaction
- Agent maintains awareness of active work
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Updates the compaction-stage “merge summaries” prompt in `src/agents/compaction.ts` to explicitly preserve agent continuity context (active task/status, batch progress, latest user request, decisions/rationale, TODOs/constraints, and promised follow-ups) and to prioritize recent context over older history when merging partial summaries during staged summarization.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Change is limited to a static instruction string used for summary merging; no control flow, types, or external interfaces change, and the new formatting (`[].join("\n")`) is straightforward.
- No files require special attention
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#20075: feat(compaction): improve merge summary instructions for better nua...
by jlwestsr · 2026-02-18
85.6%
#8896: fix: improve compaction fallback message with recovery hints
by joetomasone · 2026-02-04
84.3%
#5380: fix(compaction): include recent messages as fallback when summary u...
by Glucksberg · 2026-01-31
82.8%
#8900: fix: improve default memory flush prompts with urgency and specifics
by joetomasone · 2026-02-04
81.8%
#6108: Fix compaction producing empty summary when ctx.model is undefined ...
by GangEunzzang · 2026-02-01
81.6%
#20038: (fix): Compaction: preserve recent context and sync session memory ...
by rodrigouroz · 2026-02-18
81.4%
#9620: fix: increase auto-compaction reserve buffer to 40k tokens
by Arlo83963 · 2026-02-05
80.1%
#4223: fix: compaction safeguard falls through when ctx.model is unavailable
by hanxiao · 2026-01-29
79.5%
#9012: fix(memory): resilient flush for large sessions [AI-assisted]
by cheenu1092-oss · 2026-02-04
79.1%
#19923: feat: track held messages during compaction gate and split verifica...
by PrivacySmurf · 2026-02-18
79.0%