Tool · Agent context

Fast Jev Compaction

A Claude Code plugin and TypeScript library that uses Jev to keep, truncate, or drop older tool calls and results.

By tamaratran
THE INTERESTING PART

Keep retained context verbatim, with deterministic limits and a fallback when compaction cannot help.

Tool historyRelevance judgmentKeep / trim / drop

What it does

Fast Jev Compaction asks whether older tool calls and tool results still matter to the current agent task. It then keeps them verbatim, truncates the head of a result, or removes a paired call and result. User and assistant text remains in the output, and the Claude Code hook falls back to built-in summarization when the Jev path fails or saves too little.

What you can reuse

The library exports the useful layers separately: collecting tool calls, fitting state to a request budget, batching questions, deciding each call, applying decisions, and adapting the transport. Its policy options expose preservation windows, size ceilings, truncation length, and a keep threshold.

How it fits

An agent transcript becomes shared state. Each candidate tool interaction receives a bounded relevance decision. Deterministic code then applies the policy and reports before-and-after statistics.

Setup and compatibility

The project is documented as both an npm library and a Claude Code plugin. The plugin route currently depends on an early-access Claude Code function-hook capability and a TypeSafe API key.

Limitations

Only tool calls and results are candidates for removal. Token counts are estimates, and a probability does not prove a result is safe to discard. Near the state ceiling, the full fitted state may be repeated across requests. The repository's animated macOS demo is explicitly scripted and does not call the API.

Sources

Primary source: Fast Jev Compaction repository.

TAKE AN IDEA INTO YOUR CODE

Related copyable example

All examples →

Each example states whether its question is extracted, adapted, or independently written. It is a starting point, not the whole project.

Keep or trim a tool result

Ask whether an older tool call and its full output still matter to the current task.

Question by tamaratran
THE QUESTION · 1 OF 2

Tool call t1 (read_file) should stay in the history: knowing this call was made, with its input, still matters for what the assistant does next