Context Optimize saved 61% of input tokens on Claude Opus

Agentic sessions bloat context with repeated tool schemas and pretty-printed JSON. We benchmarked deterministic compression across 5 real scenarios.

Published 2026-03-20, updated 2026-09-24, by Dor Amir on the Nadir blog.

Filed under Nadir & Alternatives.

Correction, 24 September 2026: an earlier version of this post said every transform is lossless with zero semantic degradation, and that Context Optimize runs in safe mode by default. Neither was true. Safe mode is deterministic, but conversations past 40 user turns are trimmed, whitespace normalization flattened indentation outside code fences until 24 September 2026 (it now keeps it), and the layer stays off until you turn it on. The benchmark below is unchanged.

The problem

Agentic coding sessions are expensive because of bloated context. Every turn in a conversation accumulates:

With Claude Opus at $5/1M input tokens, this adds up fast.

What Context Optimize does

Safe mode is deterministic: no model calls, and nothing is paraphrased. It is not strictly lossless, though: history trimming drops the middle of long conversations.

TransformWhat it does
JSON minificationRemoves whitespace, newlines from JSON values
Tool schema dedupReplaces repeated tool definitions with references
System prompt dedupRemoves duplicated instructions across turns
Whitespace normalizationCollapses runs of spaces and extra blank lines outside code fences, keeping indentation
Chat history trimmingPast 40 user turns, keeps system + first + last 39 turns

Benchmark results (Claude Opus)

ScenarioBefore (tokens)AfterSaved$/1K requests
Agentic coding (8 turns, 5 tools)3,6571,57357.0%$10.42
RAG pipeline (6 chunks)54438629.0%$0.79
API response analysis (nested JSON)1,63461662.3%$5.09
Long debug session (50 turns)3,8561,41463.3%$12.21
OpenAPI spec context (5 endpoints)2,64976271.2%$9.44
Total12,3404,75161.5%$37.95

The biggest wins come from agentic sessions with repeated tool schemas and long debug sessions with JSON logs.

How to enable it

Context Optimize is off by default. Turn on safe mode in your API key config or globally:

layers:
  optimize: safe  # deterministic transforms, no model calls

The aggressive mode (semantic dedup, embedding-based redundancy removal) is available on the Pro plan.

More on nadir & alternatives

Pages on this site

Machine-readable summaries of this site: llms.txt and llms-full.txt.