32 questionsper request
~32k tokensstate + longest question
$0.042 / MTokinput; output free
70–500 msend to end
System One models · agent memory

What Jev changes about context compaction

Jev doesn't write text. It answers typed questions in milliseconds, and charges only for what you show it. That combination turns three things that were too expensive or too unreliable to do per-turn into things you can do on every tool call.

Every number on this page came out of a working implementation — the repo runs the same code offline. Nothing here is illustrative.

The shape

Gate the entrance, not the exit

Context is [frozen prefix] + [work area]. The prefix is append-only, so the KV cache over it is never invalidated and every edit happens in the tail. Tool output is judged on the way in rather than summarised on the way out.

And the gate relocates rather than deletes: what it removes goes to a store and leaves a pointer the agent can expand. Jev scores what to move out at write time and what to pull back at read time — the same call in both places.

Constraint → consequence

Billed by state, free by question

A request carries at most 32 questions against one shared state, and only input is billed. So the shape that matters is many questions over one state — and the mistake that costs real money is re-sending the same state once per item.

Scoring 120 log segments

Chunk in state — each request carries only what its questions ask about
Whole corpus in every state
Invisible unless you look at what you put in state. The implementation has a test asserting every request's state holds exactly the items its questions ask about — no more, no fewer.

Phase 0

Compact the tail, never the prefix

Eight turns of an agent session. The frozen prefix only ever grows; all the churn is in the work area. At a commit point the work area folds into the prefix and the cache boundary moves forward — it never moves back.

Buffer across eight turns

tokens
frozen prefix — cached, immutable work area — free to rewrite
The prefix frozen on turn 0 is byte-identical eight turns later. The buffer enforces that at runtime rather than trusting it: it memoises what it last rendered and raises if a commit would change any of it.

When is folding the tail in worth it? At 0.1× cache reads and 1.25× writes, compacting P down to P′ pays back after k = 12.5·P′/(P−P′) turns:

Which is the actual lesson. Cost almost always says “compact”. So the useful thing to ask Jev at a commit point isn't is this worth compacting — it's is this subtask actually finished. A safety question, not an economic one.

Phase 1

Relocate, don't delete

Jev can't generate text, which is the feature here: compaction becomes extractive. Every retained line is a verbatim original, so memory can never contain a fact some model invented while rewriting a summary of a summary.

One npm result through the gate


    
The pointer is parseable and reversible — expanding it reconstructs the original output byte for byte. Register the expand tool with the agent: a gate the agent can't undo isn't safe to turn on.

The part that used to be impossible

Tune the threshold yourself

Every decision is logged with its score. When the agent later calls expand, that's ground truth the gate was too aggressive — it went looking for exactly what was taken away. Replaying the log against a different threshold costs nothing and needs no second agent run.

Below: 15 real decisions from three turns. Three of them the agent later came back for. Drag the threshold and watch what each choice would have cost.

0.35
kept
relocated
tokens saved
still missed

That last column is what you actually tune on: of the things the agent had to go back for, how many would this threshold still have taken away. It's the number that says a gate is set too tight, and before Jev nobody could afford to collect it per-item.

Failure design

Every failure mode should cost tokens, not information

Relocation over deletion built

A false drop becomes a round trip instead of lost data. This is the one decision that makes the rest safe to turn on.

Fail open built

Jev unreachable means every item scores 1.0 and text passes through untouched. An outage degrades context to uncompacted, never to silently missing things.

A max-elide tripwire built

If the scorer wants to remove more than 70% of an output, keep all of it. A scorer that wants to drop almost everything is reporting a bad question, not a worthless output.

Protected kinds built

Stack traces and diffs survive a low score. A halved stack trace isn't a stack trace, so segmentation never splits one either.

Jev is not a security boundary. Typed output means Jev itself can't be turned into an instruction emitter — genuinely useful, and it solves the recursion problem in using an LLM to screen LLM input. But its judgement can still be influenced by the text it's judging. Tool allowlists and approval gates still apply.

Rollout

How you'd actually ship this

These steps are ordered because each one produces what the next needs. Turning a context gate straight on is how you lose a week to “the agent got worse and nobody knows when”.

  1. Phase 0 alone. The append-only buffer and a commit policy. No Jev, no store. Measure the cache hit rate you gain.

  2. Shadow mode. shadow_only=True scores and logs everything and changes nothing. A supported mode, not a debug flag.

  3. Replay to choose a threshold. The slider above, against your own traffic instead of this demo's.

  4. Turn it on and watch the false-negative rate. Above roughly 2%, the threshold is too tight.

Honest accounting

What isn't built

Four further ideas follow naturally from the same primitive, and none are implemented. Each needs metadata or hit data that doesn't exist on day one — so the hooks are in place and the collection is already running.

Jev-driven commit points not built

“Is this subtask finished?” as a typed question. Commit policies already go through a protocol so one can drop in without touching the buffer.

Multi-dimensional labelling not built

One call, ~15 parallel questions per record: type, lifecycle, entities, whether it corrects an earlier record. Memory management becomes code operating on metadata rather than a model rewriting text. The 32-question cap is the natural budget.

Supersession chains not built

Ask whether a new record replaces each candidate old one, and keep a version chain with provenance instead of a pile of contradicting facts.

Bayesian threshold calibration not built

Combine Jev's expected relevance with observed hit counts. The collection half ships now — that's what the log above is.