Project case study
tare
tare compresses agent context through a proxy, CLI, MCP server, and language libraries while protecting provider prefix caches and watching total token behavior.
Problem
Coding agents accumulate tool output, logs, file reads, JSON, and history until the context window becomes expensive or full.
Removing input tokens is not enough by itself: rewriting a cached prefix can forfeit a provider discount, and aggressive compression can make a model answer more verbosely.
Why existing approaches fall short
Most compressors optimize input tokens in one direction without observing cache-hit rate or the output tokens that follow.
Provider-native compaction is tied to one provider, command-output wrappers cover a narrower slice of context, and model-based prose compressors add weights and inference latency while remaining lossy.
Approach and architecture
Preserve information by default
The default pipeline uses reversible transforms such as columnar encoding, deduplication, cross-turn deltas, and schema slimming. Row caps, field truncation, telegraphic prose, and AST code skeletonization are opt-in.
Protect the cache boundary
The local proxy detects the provider cache breakpoint and compresses only the dynamic suffix, keeping the stable prefix byte-for-byte intact.
Close the feedback loop
A per-session controller halts when cache-hit rate suffers, backs off when output verbosity spikes, and compresses harder as context fill rises. The same engine is exposed through Rust, Python, JavaScript, the CLI, and MCP.
Proof
- Agent context
- On the committed corpus, tare compress reduced agent_context from 15,130 to 8,499 o200k_base tokens, a 43.8% reduction. Benchmark methodology and results.
- Application logs
- The opt-in compact-lossy command reduced app_log from 13,217 to 6,551 tokens, a 50.4% reduction on the committed corpus. Benchmark methodology and results.
- Code skeletonization
- The opt-in skeletonize command reduced server_rs from 5,930 to 1,582 tokens, a 73.3% reduction while retaining code structure. Benchmark methodology and results.
Key tradeoffs
- Proxy and CLI token counts use an approximate chars-per-four model; the published benchmark table uses tiktoken o200k_base instead.
- The proxy handles credentials and should run as a trusted local sidecar, not as shared multi-tenant infrastructure.
- The public benchmark notes live Anthropic smoke tests, but also says tare is not yet production-hardened or load-tested.
Lessons
- Context optimization has to account for cache economics, not only raw prompt size.
- Net tokens matter more than input tokens removed when compression can change the model's response behavior.
- A conservative default and explicit lossy controls make compression easier to reason about and reverse.