Repository navigation
Releases
v0.3.0 - deterministic-first, local Laya backend
Replaces the model-judged decision core with a deterministic one, backed by a local open-weight model. No API key, no per-request cost.
Why
v0.1 asked a hosted model a judgement per tool call. Independent measurement showed why that fails: with a noul-style primitive, factual questions are reliable (0.996 on an explicit fact) and judgement questions are not (0.003–0.28). It also cost about $1/day — a 25k-token state resent ~1,000 times a day, against a saving of $0.0001 on a model whose cached input is $0.003/M.
What changed
- Facts are computed, not guessed.
superseded,error-resolved,referenced(exact string) andsmall-resultinvolve no model. - Deletion requires deterministic evidence. A model answer can only ever cause a truncation, which keeps a bounded head plus a re-run note.
- The residual question is a
choice, not anoul. Measured against the same local model: a statement and its own negation both scored ~0.95, while the choice separated cleanly (0.75–0.99 on a real quote, 0.80–0.91 on unrelated text). - Payload per question: a few hundred tokens, down from a 25k-token wholesale state.
- Defaults to local Laya via MLX (a few hundred MB of weights, single-digit-ms per decision), with
scripts/laya-server.pyas a thin Jev-protocol transport. - Degrades to deterministic-only when the backend is absent, and
LAYA_COMPACTION=0disables it.
Verification
All five policy branches exercised end to end, against a protocol stub and against real local Laya:
A referenced -> kept
B superseded -> dropped
C error-resolved -> dropped
D small-result -> kept
E large, unmentioned-> truncated (model answered "does-not")
Naming note
The package and repository still say jev-compaction; the plugin id is laya-compaction. The backend accepts any Jev-shape endpoint via LAYA_BASE_URL, so the old name is not wrong, just stale.
v0.2.2 - telemetry and reporting
Telemetry plus the report that reads it. This is the first release that records whether a decision was a mistake, so a 0 here means "measured and fine", not "not measured".
What's measured
rerunAfterDrop/rerunAfterTruncate— a tool call re-issued with the same tool and input under a new id, after the original was removed or shortened. The direct, measurable cost of a wrong decision.tokensSavedfrom the same calibrated estimator as the threshold, notchars / 4.- Counters for
transformCalls,engaged,belowThreshold,capReached,overflow,noKey, so dormant is distinguishable from broken. - A per-session JSONL ledger, written only when a run changed something.
The report
npm run reportJoins the ledger to opencode's session records — neither half answers anything alone. Reports engagement, re-run rate with a verdict, pruned vs unpruned cohorts, before/after the install boundary, and the subagent cost share the sidebar widget surfaces.
It deliberately refuses to print a quality verdict when the installed plugin does not record re-runs. Before this, an old install produced "0% re-runs, judgement holding up" — which was the report lying, since a version that measures nothing also reports nothing.
Note
If you installed via a github: spec, the TUI half will not load: those installs land in a directory whose name contains a colon (github:owner/repo) and the TUI's module loading fails on it silently. Use the npm package.
v0.2.0 - telemetry
Telemetry, so the pruning can be judged instead of assumed.
Savings alone cannot tell you whether the decisions are good, and the previous tokensSaved was a characters-per-token guess. This release adds the measurement that matters.
Metrics
rerunAfterDrop/rerunAfterTruncate— a tool call re-issued with the same tool and input under a new id, after the original was removed or shortened. That is the direct, measurable cost of a wrong decision.tokensSavednow uses the same calibrated estimator as the threshold, instead ofchars / 4.- Counters for
transformCalls,engaged,belowThreshold,capReached,overflow,noKey, so "working well" is distinguishable from "never ran". - A per-session JSONL ledger (
~/.local/share/opencode/jev-compaction-ledger.jsonl) with tokens before/after, dropped, truncated, requests, stage and re-runs, written only when a run actually changed something.
Reading it
If rerunAfterDrop climbs alongside dropped, the keep threshold is too high or Jev is being asked to judge content it cannot see. If dropped stays near zero while belowThreshold dominates, the plugin is dormant on your sessions and the trigger is higher than they ever reach.
See the Metrics section of the README for the file layout and field list.
v0.1.1
Two plugins for opencode: a server-side pruner that replaces lossy compaction with per-call decisions, and a TUI sidebar widget reporting tokens saved.
Strategy adapted from fast-jev-compaction (MIT) — see NOTICE.
Highlights
- Asks Jev, per tool call, whether the call and whether its full output still need to be in context, then keeps, truncates, or drops. Everything else stays verbatim.
- Runs before every model request and stays dormant below
JEV_COMPACTION_THRESHOLD. - Never throws. A missing key, timeout, or malformed answer leaves the messages untouched.
- Hard daily request ceiling (default 200/day).
- Every decision is auditable:
JEV_DEBUG=1logs each score and action.
Fixed since the first cut
- Small tool results are now shown to Jev in full instead of as
ok, N chars (omitted). Hiding them meant Jev judged the value of content it could not see, and reasonably guessed "cheap to re-read" even for a short file of hard constraints. Replaying the same case through the plugin, a needed call scored 0.43 and was deleted; with the content visible it scores 0.72 and is kept. A stale build log stays low (0.25) either way. - Default keep threshold lowered from 0.5 to 0.35. A call below it is deleted outright, and 0.4–0.5 calls are ambiguous, so keeping and truncating is the safer side of that line.
- Parts are held by reference when applying decisions, so dropping one can no longer shift another in the same message.
- The daily ceiling is reserved before requests are fired, so concurrent batches cannot overshoot it.
JEV_PRESERVE_RECENTis clamped to a minimum of 1.
Install
opencode plugin opencode-jev-compaction --globalRequires a TypeSafe API key via TYPESAFE_API_KEY, or JEV_KEYCHAIN_SERVICE / JEV_KEYCHAIN_ACCOUNT to read it from the macOS Keychain.
Note on installing from GitHub
Installing via a github: spec works for the server half but not the TUI half: those installs land in a directory whose name contains a colon (github:owner/repo), and the TUI's module loading fails silently on that path. Use the npm package for both, or add the TUI widget as a local file.