Context Compression
Overview
context_compression is a route-local request plugin that reduces large
tool/function outputs before the selected provider receives the request. It is
separate from router signal compression: routing evaluates the original
request, then this plugin performs the upstream body mutation.
Compression is local, extractive, query-aware, and fail-open. It uses bounded BM25-style ranking, keeps leading and trailing context, and never changes system, user, or assistant text.
Key Advantages
- Reduces provider input tokens on tool-heavy routes.
- Keeps routing and safety signals on the original request.
- Applies per decision instead of changing every request.
- Fails open when the request cannot be parsed or rewritten.
- Preserves valid JSON structure and non-text multimodal blocks.
- Supports OpenAI tool/function messages and Anthropic
tool_resultblocks.