Skip to content

[FEATURE]: Scoped compaction — compress exploratory context segments without touching the rest #17603

Closed as not planned

Description

@cyborg42

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

Describe the enhancement you want to request

OpenCode's current compaction behavior compresses the whole session history when approaching context limits. This creates a painful tradeoff for exploratory tasks: you spend 80k tokens debugging or investigating something, reach a clear conclusion — and then compaction blurs it all into a generic summary.

The core issue: compaction is all-or-nothing. There's no way to say "compress just this investigation phase into its conclusion, leave everything else as-is."

Proposed behavior

A compact_scope tool that the agent calls retroactively after completing an exploration phase — no upfront marking needed:

# Agent calls this after reaching a conclusion
compact_scope(
  summary="Auth bug root cause: race condition in token refresh. Fix: mutex lock.",
  discard_from=5
)
# → everything from turn 5 onward is replaced with the summary; earlier context untouched

The conclusion block injected would be more precise than a global compact summary because it covers a narrow, well-defined investigation with a known outcome. The agent decides after the fact which turns to compress — no need to predict scope boundaries in advance.

Why not subagents?

Subagents solve a different problem (parallel work, isolated context). This is about the main session's own history — the agent walked down a long road, found the answer, and now needs to "squash" those turns without disturbing the surrounding context.

Analogy

git squash for context: exploratory turns collapse into one clean conclusion commit. The rest of the session log is untouched.

Additional context

Claude Code's /compact already supports custom instructions (e.g. /compact "focus on conclusions"). Scoped compaction extends this idea to sub-session granularity. It could also be exposed as an internal tool that the agent triggers autonomously when it detects a phase transition.

Activity

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

    @github-actions
    Contributor

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

  4. 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
  5. github-actions commented on Jul 7, 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