OmniRoute Compression Strategy Selector Modes: Off, Lite, Standard, Aggressive, Ultra, RTK, and Stacked
OmniRoute's compression strategy selector supports seven distinct modes—off, lite, standard, aggressive, ultra, rtk, and stacked—which are defined in open-sse/services/compression/types.ts and selected via the selectMode function in strategySelector.ts based on combo overrides, auto-trigger thresholds, or global defaults.
OmniRoute implements a sophisticated prompt-compression pipeline that automatically selects the optimal compression strategy selector mode for each request. The open-source repository defines these modes as a TypeScript union type, allowing developers to balance token savings against processing latency through explicit configuration or automatic heuristics.
How the Strategy Selector Determines the Active Mode
The selection logic resides in open-sse/services/compression/strategySelector.ts within the selectMode function. According to the OmniRoute source code, the selector evaluates configuration in the following strict priority order:
- Explicit compression combo assignment – A specific combo can force a designated mode.
- Combo-level override – Individual combos may override the system default.
- Auto-trigger thresholds – When request token counts exceed configured limits (e.g., 4,000 tokens), the selector automatically enables a higher-saving mode.
- Configured default mode – The global default stored in the database.
off– When no configuration applies, compression is disabled.
This hierarchy ensures that explicit developer configurations take precedence over automatic heuristics while maintaining fallback safety.
The Seven Compression Strategy Selector Modes
The CompressionMode type in open-sse/services/compression/types.ts defines seven operational levels. Each mode represents a specific trade-off between computational latency and token reduction efficiency.
off – No Compression Applied
The off mode disables all compression processing. Requests pass through the pipeline unmodified, incurring zero processing overhead. This mode serves as the default fallback when no compression configuration exists or when latency requirements are absolute.
lite – Fast Lightweight Optimization
The lite mode implements five inexpensive techniques: whitespace collapse, system-prompt deduplication, tool-result compression, redundant-content removal, and image-URL replacement. According to the implementation in open-sse/services/compression/lite.ts, this mode achieves approximately 10–15% token savings with less than 1 millisecond of added latency, making it ideal for high-throughput applications where minimal overhead is critical.
standard – Balanced Compression Pipeline
The standard mode activates the full compression pipeline defined in open-sse/services/compression/caveman.ts. It applies a broader mix of semantic and syntactic transformations than lite, offering significantly higher token savings while maintaining reasonable latency characteristics suitable for most production workloads.
aggressive – High-Efficiency Token Reduction
The aggressive mode employs heavier transformations including deep semantic condensation to maximize token reduction. As implemented in the core compression engine, this mode incurs additional latency compared to standard but delivers substantially higher compression ratios for complex prompts.
ultra – Maximum Compression for Large Payloads
The ultra mode utilizes all available compression techniques plus extra heuristics to achieve maximum token savings. According to the OmniRoute source code, this mode is specifically designed for very large prompts where latency is less critical than minimizing token count, processing content through the most intensive pathways in caveman.ts.
rtk – Rule-Based Terminal Output Compression
The rtk mode invokes the Rule-Based Terminal Tool (RTK) engine located in open-sse/services/compression/engines/rtk/. This specialized mode parses terminal tool output, removes ANSI noise, deduplicates lines, and optionally preserves raw output for authenticated recovery. Unlike general content modes, rtk targets specific tool-output formats for deterministic compression.
stacked – Layered Multi-Engine Composition
The stacked mode enables composition of multiple compression engines, such as combining caveman with rtk for layered processing. This mode supports complex workloads requiring different compression strategies for distinct content sections within a single request.
Configuring Compression Modes in Practice
Developers interact with these modes through the compression API endpoints defined in src/app/api/settings/compression/. The following examples demonstrate how to leverage the strategy selector programmatically.
Setting a Global Default Mode
import { getCompressionConfig, updateCompressionConfig } from '@omniroute/client';
// Retrieve current configuration
const config = await getCompressionConfig();
console.log('Current default:', config.defaultMode);
// Update global default to 'lite'
await updateCompressionConfig({ defaultMode: 'lite' });
Forcing a Mode via Combo Configuration
Combos can enforce specific modes regardless of global settings:
// Combo definition stored in the database
const comboConfig = {
id: 'combo-fast-001',
name: 'High-Speed Processing',
providers: ['openai/gpt-4o-mini'],
compressionMode: 'lite' // Forces lite mode for this combo
};
Auto-Trigger Implementation
The selector automatically escalates compression when token thresholds are exceeded:
// Logic based on the selectMode implementation in strategySelector.ts
function selectMode(requestTokens: number, config: CompressionConfig): CompressionMode {
if (requestTokens > config.autoTriggerThreshold) {
return 'standard'; // Auto-escalate from default to standard
}
return config.defaultMode;
}
Summary
- OmniRoute defines seven compression strategy selector modes in
open-sse/services/compression/types.ts:off,lite,standard,aggressive,ultra,rtk, andstacked. - The
selectModefunction instrategySelector.tschooses modes based on strict priority: combo assignment > combo override > auto-trigger > default > off. litemode provides sub-millisecond latency with 10–15% savings, whileultramode maximizes compression for large payloads at higher latency cost.rtkmode offers specialized terminal-output processing, andstackedenables multi-engine composition for complex workflows.- Configuration occurs via the API endpoints in
src/app/api/settings/compression/, supporting both global defaults and per-combo overrides.
Frequently Asked Questions
What is the default compression mode if I don't configure anything?
OmniRoute defaults to the off mode when no configuration exists. The selectMode function falls back to this state when it cannot find a combo assignment, override, or auto-trigger threshold that applies to the current request.
How does the lite mode achieve such low latency?
The lite mode limits processing to five cheap syntactic transformations—whitespace collapse, system-prompt deduplication, tool-result compression, redundant-content removal, and image-URL replacement—without performing expensive semantic analysis. This constrained scope, implemented in open-sse/services/compression/lite.ts, keeps processing time under 1 millisecond while delivering approximately 10–15% token savings.
Can I use multiple compression modes simultaneously?
Yes, through the stacked mode, which composes multiple engines such as caveman and rtk to apply different compression strategies to different parts of a request. This layered approach allows sophisticated pipelines where, for example, general content undergoes semantic compression while terminal output receives rule-based processing.
When should I choose aggressive over standard mode?
Select aggressive mode when your prompts contain substantial redundant semantic content and you prioritize token savings over response latency. According to the source implementation in open-sse/services/compression/caveman.ts, this mode activates deeper semantic condensation algorithms that require more processing time but yield significantly higher compression ratios than standard.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →