Oleksandr Kuzmenko, EditorPublished 6 min readAI-assisted · editor-reviewed
TL;DR
- Replaces context-destroying summaries by pruning only obsolete tool calls and outputs.
- User prompts, assistant code, and reasoning steps are preserved verbatim.
- Automatically falls back to built-in compaction if size reduction is less than 25%.
Key facts
- Default maxStateTokens
- 25,000
- Default maxRequestTokens
- 30,000
- Minimum compaction reduction ratio
- 0.25 (25%)
- Minimum Claude Code version
- 2.1.274+
Source: Key facts — Minimum compaction reduction ratio, Minimum Claude Code version
Source: Key facts. Minimum compaction reduction ratio: 0.25 (25%). Minimum Claude Code version: 2.1.274+. Each figure is copied from the story.
- Minimum compaction reduction ratio0.25 (25%)
- Minimum Claude Code version2.1.274+
Source: Key facts — Default maxStateTokens, Default maxRequestTokens
Source: Key facts. Default maxStateTokens: 25,000. Default maxRequestTokens: 30,000. The chart compares only values that share a unit. Each figure is copied from the story.
Metric chart
- 25,000Default maxStateTokens
- 30,000Default maxRequestTokens
- Default maxStateTokens25,000
- Default maxRequestTokens30,000
Verbatim History Over Lossy Summaries
When long agent sessions trigger context compaction, standard summaries often wipe out essential constraints like "never edit src/generated" or nuanced syntax errors. The fast-jev-compaction utility acts as both a standalone npm package and a Claude Code hook plugin that preserves conversation messages verbatim while selectively pruning obsolete tool calls.
How Jev Scoring Works
1. State Fitting: The session state is fitted into maxStateTokens (default 25,000) using progressive compression: tool inputs drop from 1000 to 200 to 60 characters, and long texts collapse to head/tail slices. 2. Decision Matrix: For each tool call, Jev scores two questions against keepThreshold: should the call stay, and should the result stay verbatim? 3. Pruning Execution: If keepResult meets the threshold, both call and output remain. If only keepCall passes, the result is truncated to truncateHeadChars with a stub notice. If neither passes, the entire call and result pair is removed. 4. Fallback Handling: If the transcript cannot be fitted or the reduction ratio is under 0.25 (25%), Claude Code safely falls back to standard compaction.
Setup via Function Hooks
Function hooks require Claude Code 2.1.274 or newer with the experimental flag enabled in ~/.claude/settings.json:
{
"env": {
"CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1",
"TYPESAFE_API_KEY": "<your-key>"
}
}Try it in 2 minutes
claude plugin marketplace add tamaratran/fast-jev-compaction
claude plugin install fast-jev-compaction@fast-jev-compactionWhen to use
- Use in multi-hour autonomous coding loops where tool outputs quickly saturate the context window.
- Use when standard compaction summaries cause your agent to forget previous architectural constraints.
When NOT to use
- Do not use if you lack a TypeSafe API key or run completely offline environments.
- Avoid for tiny sessions where context size never approaches the compaction boundary.
What to do today
- Set CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 in your Claude Code environment configuration.
- Install the marketplace plugin via claude plugin install fast-jev-compaction@fast-jev-compaction.
- Export your TYPESAFE_API_KEY to test verbatim context compaction on heavy coding tasks.
Step names are taken from What to do today.
Step names are taken from What to do today. Set CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 in your Claude Code environment configuration.. Install the marketplace plugin via claude plugin install fast-jev-compaction@fast-jev-compaction.. Export your TYPESAFE_API_KEY to test verbatim context compaction on heavy coding tasks.
- Set CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 in your Claude Code environment configuration.
- Install the marketplace plugin via claude plugin install fast-jev-compaction@fast-jev-compaction.
- Export your TYPESAFE_API_KEY to test verbatim context compaction on heavy coding tasks.
