anomalyco / anomalyco/opencode
[FEATURE]: Implement V2 manual compaction
@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/compactsilently do nothing on such models. - Automatic compaction retains
compaction.keep.tokensof 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.