Skip to content

[FEATURE]: Pointer-based retrieval for compacted tool results #22407

Closed as not planned

Description

@joshuaisaact

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:

  1. list_refs() — returns all compacted parts for the current session with IDs, titles, and sizes
  2. read_ref(id) — returns the full original part.state.output for 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

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Apr 14, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 14, 2026
  3. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions