← Reddit

I cut 47% of Claude Code's tool-result tokens by replacing token transport with deterministic hooks

Reddit · Clear_Sights · July 10, 2026
Lever, an open-source project, reduces token usage in Claude Code by 47% through a content-addressed store that eliminates "transport" tokens by storing large content separately instead of including it directly in context. The system provides the model with addresses and retrieval commands to access needed portions, and also enables caching of repeated prompts and makes subagent results directly addressable through deterministic hooks.

Detailed Analysis

A developer building on Claude Code has released Lever, an open-source project (Apache 2.0) that tackles a specific inefficiency in how coding agents consume tokens: the sheer volume of "transport" data — raw tool outputs, fetched web pages, re-read files, and repeated command results — that gets poured wholesale into an LLM's context window even though the model never needed most of it. The tool works through Claude Code's existing hooks system, intercepting tool calls before their results become tokens. Instead of dumping a 20,000-character page fetch or command output directly into context, Lever routes it into a local content-addressed store and gives the model a bounded preview window plus a precise address and retrieval command for the rest. The model then pulls only the slices it actually needs. On the author's own build sessions, this approach cut tool-result bytes entering context by 47% and extended the point at which Claude Code's auto-compact mechanism kicks in by roughly an hour.

The significance of this approach lies in its philosophical framing: an LLM's core value is reasoning, and everything else — fetching, quoting, re-reading — is mechanical transport that doesn't require model involvement at all. This is a meaningfully different strategy from most context-management approaches, which tend to focus on summarization or compaction after the fact (asking the model itself to compress its own history). Lever instead prevents unnecessary tokens from entering context in the first place, using deterministic, content-addressed storage and exact-match predicates rather than probabilistic judgments. The author explicitly rejected a fuzzy-similarity approach after it scored a near-duplicate file as only 78% similar to an identical one — a reminder that in agentic tooling, non-deterministic shortcuts can silently corrupt correctness in ways that are hard to detect. The system also memoizes repeated prompts and subagent outputs as addressable artifacts, and uses "redirects" to translate raw commands (like a Bash grep) into their tool-native equivalents or to flag no-op writes, but treats these as boundary optimizations rather than the core mechanism.

This development sits within a broader and increasingly urgent conversation about the economics and reliability of long-running coding agents. As Claude Code and similar tools (Cursor, Devin, Aider, OpenAI's Codex CLI) are used for longer, more autonomous sessions, context-window exhaustion and auto-compaction become practical bottlenecks — compaction can lose fidelity, cost latency, and interrupt an agent's task momentum. Anthropic itself has been iterating on context management, memory tools, and prompt caching to address exactly this class of problem, and third-party tooling built on Claude Code's hook/plugin architecture — as Lever is — reflects how the developer ecosystem is extending Anthropic's agent framework in ways the company didn't necessarily build natively. The fact that Claude Code exposes hooks flexible enough to let an outside developer reroute tool-result handling entirely is itself notable: it signals a plugin-friendly architecture that invites this kind of infrastructure experimentation rather than locking behavior into Anthropic's own defaults.

More broadly, Lever is representative of a maturing pattern in agent engineering: treating token efficiency as a systems-design problem rather than a prompting problem. Rather than asking the model to be more concise or relying on ever-larger context windows to paper over waste, the approach applies classic software engineering ideas — content-addressed storage, memoization, deterministic caching, pointer-based dereferencing — to a domain that has largely been managed through brute-force scaling of context length and inference cost. The author's transparency about limitations (self-reported, session-specific numbers; a 60ms-per-call Python overhead pending a Go rewrite; two anticipated features that measured out near zero and were deliberately not shipped) also reflects a broader shift toward empirical, benchmark-driven tool-building in the AI agent space, where claims are increasingly expected to be replayable and falsifiable rather than taken on faith. As agentic coding tools proliferate, this kind of "transport vs. reasoning" separation could become a standard architectural pattern well beyond Claude Code specifically.

Read original article →