anomalyco / anomalyco/opencode

[FEATURE]: Implement V2 manual compaction

Open
#40,614 1 comment 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Aug 5, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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

SessionV2.compact is a stub that fails with OperationUnavailableError (packages/core/src/session.ts), which the server maps to a 503. So on V2 there is no manual compaction: /compact only appears to work in the app because the compat shim rewrites it to the legacy V1 session.summarize.

V2 already has automatic compaction (request-budget) and overflow-triggered compaction. What's missing is the explicit, user-initiated path.

This is already recorded as a follow-up in specs/v2/session.md:

Add explicit manual compaction on top of automatic request-budget compaction.

and in specs/v2/schema-changelog.md:

Defer provider-overflow recovery, explicit manual compaction, and deterministic old tool-result pruning.

Overflow recovery has since landed; manual compaction has not.

Notes on what makes it distinct from the automatic path:

  • It should not be a provider turn — no inbox promotion, no tool materialization, no assistant reply.
  • The two budget conditions shouldn't apply, since the request is explicit rather than a response to context pressure. In particular, automatic compaction declines when a model declares no limits.context, which would make /compact silently do nothing on such models.
  • Automatic compaction retains compaction.keep.tokens of verbatim recent context because it only needs to free enough budget to continue. An explicit request should compress the whole active history.
  • It needs to be serialized against that session's provider turns without joining an active drain or coalescing with another request.

No schema change is needed: SessionEvent.Compaction.{Started,Ended} and SessionMessage.Compaction already declare reason: "auto" | "manual", and "manual" currently has no producer outside tests.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.