Skip to content

feat(opencode): prune old tool outputs before compaction#14827

Open
praxstack wants to merge 2 commits intoanomalyco:devfrom
praxstack:feat/prune-before-compaction
Open

feat(opencode): prune old tool outputs before compaction#14827
praxstack wants to merge 2 commits intoanomalyco:devfrom
praxstack:feat/prune-before-compaction

Conversation

@praxstack
Copy link

Issue for this PR

Closes #14825

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds SessionCompaction.prune() before both compaction triggers in prompt.ts:

  1. Proactive overflow check (before calling LLM)
  2. Reactive compact result (after processor returns "compact")

Pruning strips old tool outputs (read/grep/list results) first, maximizing context reduction before the compaction summary LLM call. This prevents the summarization itself from hitting context limits.

How did you verify your code works?

  • Typecheck passes
  • Code trace verified: prune runs before SessionCompaction.create in both paths
  • Prune system already battle-tested (called at end of prompt loop)

Screenshots / recordings

Backend-only change, no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add SessionCompaction.prune() calls before both compaction triggers:
1. Proactive overflow check (before LLM call)
2. Reactive compact result (after LLM returns 'compact')

Pruning strips old tool outputs first, maximizing context reduction
before the compaction summary LLM call. This prevents the
summarization itself from hitting context limits.
@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found a potentially related PR:

Related PR:

The current PR (#14827) addresses issue #14825 and complements #14826 by adding proactive and reactive pruning of old tool outputs to prevent context limits during the compaction summarization process itself.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compaction should prune old tool outputs before generating summary

1 participant