Evidence-aware transforms
Transforms operate over typed conversational structure rather than unstructured text slicing.
Context infrastructure · Open source
A sufficiency-gated context compiler for LLM agents—built to reduce token load without removing the evidence required for the next decision.
System architecture
TokenOpt treats context as a structured build artifact. A typed IR enables deterministic transforms, the oracle evaluates whether retained evidence is sufficient, and cold-store references keep removed material recoverable.
Engineering choices
The architecture separates representation, optimization, verification, and delivery so teams can tune savings while retaining visibility into what changed.
Transforms operate over typed conversational structure rather than unstructured text slicing.
A shared budget and cross-agent deduplication prevent each specialist from paying for the same context.
Cold-store references preserve a route back to removed content when later reasoning requires it.
Technology foundation
A Rust optimization core is exposed through service, command-line, language-client, and native-binding surfaces so teams can adopt the compiler where their agents already run.
Solution fit
Most context strategies cut cost by deleting the oldest turns and hoping nothing important was in them. TokenOpt reduces by value rather than position, verifies sufficiency before it emits, and keeps a route back to whatever it removed.
Recency truncation discards the oldest turns regardless of what they contained. TokenOpt masks stale tool output while preserving the evidence the next decision depends on — a 30–70% final-turn reduction in the documented benchmark.
A shared global budget allocates spend across specialists and cross-agent deduplication removes repeated history, so a five-agent team does not buy the same transcript five times over.
Every compilation emits statistics and cold-store references alongside the messages, so a team can show exactly what was removed and recover it when later reasoning calls for it.
| Capability | Typical market approach | TokenOpt |
|---|---|---|
| Reduction strategy | Fixed-window truncation or “keep the last N messages”, which discards evidence by position. | A typed intermediate representation drives evidence-aware transforms that reduce by value, not recency. |
| Safety of the cut | The reduction is applied blind; the agent discovers the missing evidence only when it answers wrongly. | An explicit sufficiency gate evaluates retained evidence and blocks emission until the next decision is supportable. |
| Recovering removed content | Removed turns are gone for the remainder of the session. | Cold-store references keep a route back to removed material whenever later reasoning needs it. |
| Multi-agent economics | Each agent optimizes in isolation and re-pays for shared history. | Global budget allocation plus cross-agent deduplication across the whole specialist team. |
| Visibility | Savings are inferred after the fact from the invoice. | Per-compilation statistics and references are returned with the optimized messages. |
| Adoption path | Framework-locked, so adopting it means rewriting the agent loop. | One Rust core exposed through an HTTP service, the ctxc CLI, TypeScript and Python clients, and native bindings. |
Comparison note: the market column describes the default behaviour of widely used context-window strategies — recency truncation and fixed summarization — rather than any named vendor product. The 30–70% figure is TokenOpt’s documented synthetic benchmark for masking old tool outputs; realized savings depend on transcript shape and policy configuration.
Related systems
Metric note: the 30–70% result is from the repository’s documented synthetic benchmark when masking old tool outputs. Actual savings depend on transcript shape, model behavior, and policy configuration.
Discuss architecture, measurement, and production adoption.