Skip to content

Use native OpenCode compaction lifecycle - #70

Open
ishaanxgupta wants to merge 6 commits into
mainfrom
codex/fix-native-compaction
Open

ishaanxgupta wants to merge 6 commits into
mainfrom
codex/fix-native-compaction

Conversation

@ishaanxgupta

@ishaanxgupta ishaanxgupta commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

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.compacting to 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.

  • compactionEnabled turns this off for both generations. A legacy compactionThreshold of 0 or false now disables it too, instead of silently falling back to 0.8.
  • The installer no longer disables Oh My OpenCode's recovery hook, since Supermemory no longer starts compactions of its own. The README is updated to match.

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.

Before After
After a 170K-token turn plugin compacts and sends "Continue" nothing, OpenCode decides
Agent after compaction switched from build to general stays on build
Project memories in OpenCode's summary request no yes
Summary saved as a memory no yes, once
  • bun run typecheck, bun test (33 pass) and bun 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.

@ishaanxgupta ishaanxgupta changed the title [codex] Use native OpenCode compaction lifecycle Use native OpenCode compaction lifecycle Aug 12, 2026
@ishaanxgupta
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant