Skip to content

Prune is too aggressive for long-context models and should scale with model context #16285

Closed

Description

@nyl199310

Problem

SessionCompaction.prune() currently uses fixed thresholds:

  • PRUNE_PROTECT = 40_000
  • PRUNE_MINIMUM = 20_000

and runs after each assistant turn.

That means old tool outputs start being replaced with [Old tool result content cleared] after only ~40K protected tool-output tokens, regardless of whether the active model has a 128K, 200K, or 1.05M context window.

Why this feels wrong on 1M-context models

Full compaction already looks at model limits, but prune does not. So on long-context models, prune can start clearing old tool results very early even when the session is still nowhere near the actual compaction / overflow threshold.

In practice this feels like premature memory loss on large-context models: the model still has plenty of room left, but important older tool output is already gone.

Current workaround

There is a boolean escape hatch via compaction.prune: false, but that is all-or-nothing. There is no way to tune the thresholds.

Request

Could you consider one or more of the following?

  • scale prune thresholds from model.limit.context
  • add config for thresholds such as prune_protect / prune_minimum
  • make prune less aggressive automatically for very large-context models
  • expose clearer logs / UI around what was pruned and why

I think this would make long-context models behave much more intuitively.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 6, 2026
  2. github-actions commented on Mar 6, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • This appears to be a feature request, but the title does not start with [FEATURE]: and the feature request issue template was not used. Please resubmit using the feature request template, which requires a verification checkbox and description, with the title prefixed by [FEATURE]:.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. nyl199310 commented on Mar 6, 2026

    @nyl199310
    Author

    Closing this in favor of #11930, since that issue is already tracking configurable compaction behavior.

    I added a follow-up comment there with the prune-specific details from this issue, because my main concern is that prune currently uses fixed thresholds and feels too aggressive on long-context models.

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)needs:complianceThis means the issue will auto-close after 2 hours.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions