Documentation
¶
Overview ¶
ctxgate cuts token spend without a human step and without thinning what the model reasons from.
ctxgate --precompact # a PreCompact hook: what to keep, what to drop ctxgate --hook [--max N] # a PreToolUse hook on SendMessage ctxgate report [--since 168h] # the context-size distribution of the calls
⛔ WHY IT EXISTS. Measured 2026-11-20 over 7 days and 104,263 API calls: cost is the re-reading of huge contexts. Calls carrying >= 400k tokens are 36 % of the calls and 64 % of every cache-read token; sonnet sub-agents carry 23 % of the cache reads in those buckets, because a resumed sub-agent keeps its whole history and the rule "follow-ups go to the SAME agent" resumes it again and again. One agent accumulated more than 900k. No hook can trigger a compaction, so the two levers are the text a compaction is told to preserve, and a refusal to resume an agent that has grown past a cap.
A refusal is not a verdict: whatever ctxgate cannot read, it allows.