The documented "Preemptive Compaction" (triggers at 80% context) actually fires at ~14–17% for 1M-token models, compacting sessions repeatedly and prematurely.
Root cause: getModelLimit() relies on a fire-and-forget ctx.client.provider.list() at plugin init. When it fails (intermittent TypeError: terminated / fetch failed), modelLimits stays empty and compaction falls back to DEFAULT_CONTEXT_LIMIT = 200000. For a 1M model: 0.8 × 200_000 = 160_000 ≈ 16%.
Evidence (~/.opencode-supermemory.log):
[compaction] checking: {... "totalUsed":150933, "contextLimit":200000, "usageRatio":"0.75", "threshold":0.8}
[compaction] triggering compaction: {... "usageRatio":0.84566}
The model's real limit is 1M (limit.context = 1000000), so 160K is 16% of capacity.
Proposed fix:
- Retry the model-limit load (with backoff) instead of one fire-and-forget attempt.
- Raise
DEFAULT_CONTEXT_LIMIT (200K is outdated for 1M models) or derive it per-model.
- Optionally make the fallback configurable via
supermemory.json.
Environment: opencode 1.18.x (desktop 1.18.32), opencode-supermemory 2.0.12 (also 2.0.13), model deepseek/deepseek-v4-pro (1M context).
The documented "Preemptive Compaction" (triggers at 80% context) actually fires at ~14–17% for 1M-token models, compacting sessions repeatedly and prematurely.
Root cause:
getModelLimit()relies on a fire-and-forgetctx.client.provider.list()at plugin init. When it fails (intermittentTypeError: terminated/fetch failed),modelLimitsstays empty and compaction falls back toDEFAULT_CONTEXT_LIMIT = 200000. For a 1M model:0.8 × 200_000 = 160_000≈ 16%.Evidence (
~/.opencode-supermemory.log):The model's real limit is 1M (
limit.context = 1000000), so 160K is 16% of capacity.Proposed fix:
DEFAULT_CONTEXT_LIMIT(200K is outdated for 1M models) or derive it per-model.supermemory.json.Environment: opencode 1.18.x (desktop 1.18.32), opencode-supermemory 2.0.12 (also 2.0.13), model
deepseek/deepseek-v4-pro(1M context).