Repository navigation
Use native OpenCode compaction lifecycle - #70
Open
ishaanxgupta wants to merge 6 commits into
Open
ishaanxgupta wants to merge 6 commits into
ishaanxgupta wants to merge 6 commits into
Conversation
ishaanxgupta
marked this pull request as ready for review
August 12, 2026 15:32
AlexMKX
pushed a commit
to GFN-CIS/opencode-supermemory
that referenced
this pull request
Aug 26, 2026
Upstream is not fixed as of 2026-08-26 (npm 2.0.12, HEAD e9ef0f1 still has DEFAULT_CONTEXT_LIMIT = 200_000), but issue supermemoryai#69 documents the bug class and PR supermemoryai#70 ("Use native OpenCode compaction lifecycle", open since 2026-08-12) is a superset of this patch -- it hands the trigger to OpenCode natively and keeps the memory-injection feature this fork drops. Records the exit condition explicitly: when supermemoryai#70 merges, delete this fork rather than maintaining the branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #69, #85 and #88 for OpenCode V1. OpenCode 2 already worked this way.
The V1 plugin ran its own compaction: it estimated context usage, called
session.summarize, then sent a synthetic "Continue" message. That caused four bugs:Now OpenCode decides when to compact, which model summarizes, and how the session continues. The plugin hooks
experimental.session.compactingto add bounded project memories to OpenCode's own compaction prompt. It then saves each successful summary as a memory, with a stable id per summary and the same 3 s timeout as other automatic saves. Failed or empty compactions are not saved, and a failed save retries on the next idle event.compactionEnabledturns this off for both generations. A legacycompactionThresholdof0orfalsenow disables it too, instead of silently falling back to 0.8.Testing
Real OpenCode V1 1.18.35 and 1.18.23 in a sandboxed home, with a mock model and a mock Supermemory API. The model's context size is unknown, which is the lookup-failure case from #85. One turn reports 170K tokens used, then OpenCode compacts the session.
buildtogeneralbuildbun run typecheck,bun test(33 pass) andbun run build.Testing on V1 needed #111. Without it, every published version since 2.0.15 fails to load in OpenCode V1, so merge #111 first.