From 237fb8d6d0c9b4ea3b6ffa2b38f58d3065acca7d Mon Sep 17 00:00:00 2001 From: rUv Date: Tue, 10 Feb 2026 20:20:48 +0000 Subject: [PATCH] Checkpoint: File edits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatic checkpoint created by Claude Code - Branch: rebrand/ruvflow-umbrella - Timestamp: 2026-02-10T20:20:48Z - Changes: 1 file(s) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .claude/helpers/aggressive-microcompact.mjs | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .claude/helpers/aggressive-microcompact.mjs diff --git a/.claude/helpers/aggressive-microcompact.mjs b/.claude/helpers/aggressive-microcompact.mjs new file mode 100644 index 0000000000..a63b7d4b8c --- /dev/null +++ b/.claude/helpers/aggressive-microcompact.mjs @@ -0,0 +1,36 @@ +#!/usr/bin/env node +/** + * Aggressive Micro-Compaction Preload + * + * Claude Code's micro-compaction (Vd function) only prunes old tool results + * when context is above the warning threshold (~80%) and only if it can save + * at least 20K tokens. These hardcoded thresholds mean context can grow large + * before any pruning happens. + * + * This script patches the environment to make micro-compaction more aggressive + * by lowering the threshold at which it activates. It works by setting + * CLAUDE_AUTOCOMPACT_PCT_OVERRIDE to trigger compaction earlier if micro-compaction + * isn't enough, but the real win is keeping context lean through early pruning. + * + * The micro-compact function Vd() works like this: + * 1. Collects all tool results from: Read, Bash, Grep, Glob, WebSearch, WebFetch, Edit, Write + * 2. Keeps the last 3 tool results intact (Ly5=3) + * 3. If total tool result tokens > 40K (Ny5) AND context is above warning threshold: + * - Replaces old results with "[Old tool result content cleared]" + * - Only if savings >= 20K tokens (qy5) + * 4. This runs on EVERY query — it IS automatic pruning + * + * The problem: Ny5=40000 and qy5=20000 are hardcoded. We can't change them. + * The solution: Set CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 so the warning/error + * thresholds drop, which makes micro-compaction activate much earlier. + */ + +// This file is sourced by settings.json hooks to document the strategy. +// The actual configuration is in settings.json env vars: +// CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 → lowers all thresholds +// autoCompactEnabled=true → enables the auto-compact fallback + +console.log('[AggressiveMicrocompact] Strategy: CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50'); +console.log('[AggressiveMicrocompact] Micro-compact activates when tokens > warning threshold'); +console.log('[AggressiveMicrocompact] Warning threshold = maxTokens - 20K (relative to override)'); +console.log('[AggressiveMicrocompact] Effect: pruning starts at ~45% instead of ~80%');