jev-compaction-plus
Claude Code compaction in about half a second instead of about 35.
When a Claude Code session fills up, /compact makes Opus stop, re-read the whole
conversation and write a summary. This plugin hands that job to
Jev, TypeSafe's
System One decision model. Jev doesn't write anything. It decides, for every old
tool result, whether you still need it:
- whatever it keeps stays word for word;
- whatever it drops moves to a drawer file that Claude can read back.
It's a fork of fast-jev-compaction
with three fixes that made the difference on a very large session (see below).
Results
One real Opus 5.5 session in Claude Code, grown to 591,489 tokens: a whole demo
codebase, an 8,000-line log and a test run. We compacted it inside the live
session, then asked 6 questions about details from early in the session (a
trace id, a config value, an exact buggy line, and so on), with no tools allowed.
| Time to compact | Memory quiz | Tokens left |
|---|
Built-in /compact (Opus writes a summary) | 35.1 s | 6/6 | ~16k |
| fast-jev-compaction (original) | 0.35 s | 5/6 | ~7k |
| jev-compaction-plus | 0.43–0.74 s | 6/6 (3 runs) | ~26k |
- Speed: about 50-80× faster than the built-in compaction.
- Usage: it never calls Opus. Each compaction costs a fraction of a cent of Jev.
- Memory: it matched the built-in compaction on the quiz.
- The original plugin forgot a config value. It had dropped an 833-character file without ever seeing what was inside.
- Drawer test: after compacting, we asked for one exact line from an old
pytest -v run that had been moved out, and said not to re-run anything. Claude noticed the output was gone, opened the drawer file and quoted the line.
These numbers come from one session and one quiz, so treat them as an example, not a benchmark.
How it works
/compact (or auto-compact at 60% context)
│
▼
Jev gets the conversation (texts + tool calls) and, for every old tool result,
a yes/no question that quotes a preview of that result:
"does the assistant still need this output word for word?"
│
├─ yes ............................ result stays, word for word
├─ no, but it's tiny (<1,500 chars) result stays (dropping it saves nothing)
└─ no ............................. result moves to .jev-drawer/<time>/t12-Read.txt;
the session keeps the call plus a one-line label:
[Jev compaction moved this 48213-char output to
…/.jev-drawer/…/t12-Read.txt. Read that file if
you need it again.]
- Always kept:
- your messages and Claude's replies, which are never touched;
- the first message;
- the newest 6 messages.
- Fallback: if Jev fails, or can't cut at least 25%, Claude Code's normal summary runs instead.
- The drawer: each compaction gets its own folder, with an
INDEX.md listing what was moved. The drawer has its own .gitignore, so it never ends up in a commit.
What's different from fast-jev-compaction
- Jev sees what it judges.
- The original sent Jev a one-line note per result (
Read config/app.env → ok, 833 chars (omitted)), so Jev decided from the file name.
- Here, each question quotes the start and end of the result (600 characters by default).
- Tiny results always stay. Results under 1,500 characters are kept, because dropping them saves almost nothing and they're often exactly the value you need later.
- Dropped doesn't mean deleted. Dropped results go to the drawer, and the call stays in the session with a label pointing at the file. A wrong decision costs one file read, not a lost fact.
- Bug fix for split replies.
- Claude Code stores one Opus reply that makes several tool calls as several pieces sharing one message id.
- Rewriting the "tool call" piece breaks that link, and Claude Code then reports the sibling results as "Tool result missing due to internal error".
- This version only rewrites the result piece.
- Either key works. A TypeSafe key goes to TypeSafe's API. An OpenRouter key (
sk-or-…) goes to OpenRouter's decisions API (typesafe/jev-1.13) automatically.
Install
You need:
- Claude Code with function hooks: version 2.1.274 or newer (tested on 2.1.282). Function hooks are early access, so turn them on with
CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1.
- A Jev key: either a TypeSafe key or an OpenRouter key.
Put both in ~/.claude/settings.json, so every session (terminal, desktop app, IDE) sees them:
{
"env": {
"CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1",
"TYPESAFE_API_KEY": "<your TypeSafe or OpenRouter key>"
}
}
Then install the plugin: