Skip to content

Compaction: Pruning/soft compaction and selective tool-output deletion #50

@riatzukiza

Description

@riatzukiza

Epic: #46

Summary

Use pruning/soft-compaction to reclaim tokens by deleting stale tool outputs instead of resorting to full compaction.

Problem

  • Most tokens accrue in tool outputs between recent user turns.
  • Current pruning protects the exact region with heavy tool output; premature full compaction follows.

Proposal

  • Tune PRUNE_* thresholds; prefer deleting earlier completed tool outputs.
  • Consider soft-compaction: mark tool calls with IDs, let model propose safe deletions, then drop those parts and add a soft-compaction note.
  • Provide a manual /prune command and improve auto-triggering heuristics.

Code Refs

  • packages/opencode/src/session/compaction.ts:50 (prune function)
  • packages/opencode/src/session/compaction.ts:43-45 (PRUNE_* constants)

Tasks

  • Adjust prune strategy to favor pruning old completed tool outputs
  • Add logs: pruned tokens, protected tokens, decisions
  • (Optional) Implement soft-compaction workflow
  • Add /prune command or integrate into /status

Acceptance Criteria

  • Token usage reduced via pruning without harming recency.
  • Fewer full compactions during long BUILD sessions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions