Repository navigation
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
After compaction, cleared tool results are replaced with [Old tool result content cleared]. The original content persists in the database (part.state.output), but the model has no way back to it. Any question requiring a specific detail from a cleared result gets answered from whatever the summary preserved, or hallucinated.
This gets worse with cascaded compaction. Each summarization round is a lossy pass - by the second compaction, specific details from early in the session are effectively gone.
Give the model two retrieval tools for compacted content:
list_refs()— returns all compacted parts for the current session with IDs, titles, and sizesread_ref(id)— returns the full originalpart.state.outputfor a compacted part
And emit pointer IDs where cleared content used to be:
// Before:
const outputText = part.state.time.compacted
? "[Old tool result content cleared]"
: part.state.output
// After:
const outputText = part.state.time.compacted
? `[ref:${part.id} — ${part.state.title}]`
: part.state.output
Implementation cost is low: one line changed, ~80 lines of new code, no new database tables or infrastructure. The content is already stored.
I ran a series of experiments testing this against summarization-only compaction. Full methodology and experiment repo: https://github.com/joshuaisaact/pointer-experiments Writeup: https://joshtuddenham.dev/blog/compaction/
Single compaction (simulating opencode's 60% pruning rate):
| Fixture | Baseline | Pointer | Delta |
|---|---|---|---|
| migration-error (exact PG error) | 47% | 83% | +36 |
| perf-debug (EXPLAIN ANALYZE) | 72% | 50% | -22 |
| lock-timeout (config params) | 80% | 83% | +3 |
| full-refactor-session (18 parts) | 70% | 78% | +8 |
| Mean | 67% | 74% | +7 |
Cascaded compaction (x2):
| Strategy | x1 | x2 |
|---|---|---|
| summarize | 84% | 74% |
| pointerize | 85% | 92% |
Summaries of summaries lose specific details.
Pointers don't degrade because the stored content is lossless.
Related issues:
#16512, #20246, #16960 identify related symptoms (detail loss, instruction loss after compaction). Those propose better summaries or re-injecting instructions. This proposes making the original content retrievable.
Activity
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.