LCC / Act2 Router

Context Optimization Engine & Token Compressor

Status: PUBLIC Category: AI Engineering
02 · The bottleneck

What was breaking

AI applications and multi-agent loops generating excessive API billing due to bloated, redundant, and slow prompt contexts.

03 · Root diagnosis

Why standard workarounds failed

Absence of a deterministic, local-first sanitization and compression layer prior to dispatching payloads to LLMs.

04 · System engineered

Architecture & delivery

Local-first semantic deduplication, context budgeting, and deterministic compression engine requiring zero network latency or API keys.

Local toolkit to clean, dedupe, structure, and budget context before dispatching to LLMs.

Outcome

Measured & documented impact

Across 299 long Claude Code sessions (100+ messages, offline): median 21.8% fewer tokens (middle half 15%–31%, best 65%) with 0 messages lost; across 24,100 public SWE-smith trajectories (stashed mode): 16.4% on tool-call sessions (5.8% overall) with 0 byte-integrity violations.

Stack & components

Production architecture

  • AST Syntax Parser
  • Deterministic Token Compressor
  • Context Budget Allocator
  • CLI / SDK Interface
PythonTypeScriptAST ParserDeduplication Engine