Skip to main content

Overview

Compact compresses chat history and code context at 33,000 tok/s by removing irrelevant lines. Every surviving line is byte-for-byte identical to the original input. 100K tokens compresses in under 2 seconds. Pass query to tell the model what matters for the next LLM call. Without it, the model auto-detects from the last user message.

Usage Examples

keepContext Tags

Wrap sections you never want compressed in <keepContext> / </keepContext> tags. Tagged content survives compression verbatim regardless of the compression ratio.
The response includes kept_line_ranges showing which lines were force-preserved.

Compatible Endpoints

Compact also works through OpenAI-compatible endpoints with model: "morph-compactor": See the full Compact documentation for SDK reference, best practices, and advanced usage.