Glossary · Updated 2026-10-19
What is context compression for AI agents?
Context compression for AI agents is any technique that shrinks the text an agent sends to its model, such as tool output, file contents, history and retrieved documents, while keeping what the current task needs. Methods include truncation, summarization, token pruning, offloading, and query-aware extraction of relevant lines.
Why do agents need it?
An agent loop re-sends its accumulated context on every step. Each tool result therefore costs tokens many times, and long contexts raise the odds of errors and hit window limits. Compression attacks the size of what gets re-sent.
What are the main methods?
- Truncation: keep the head, tail or both. Cheap, ignores relevance.
- Summarization: an LLM rewrites history or results. Compact but lossy, and can introduce errors.
- Token pruning: a small model drops low-information tokens. LLMLingua from Microsoft is the best known example; it uses a small language model to score tokens. Source: LLMLingua on GitHub.
- Rule-based filters: content-type reducers for logs, JSON, diffs and command output, as in Headroom and RTK.
- Offloading: store the full payload and keep a preview plus handle.
- Query-aware extraction: keep original lines selected against the current question.
How does SuperCompress approach it?
SuperCompress is hosted, query-aware and extractive. The hosted Neural Keep model reads the question and the bulky context, keeps the original lines that answer it, and drops the rest. It never paraphrases, which matters for code, paths and error messages. Coding agents reach it through the compress_context MCP tool and hooks; apps call POST /api/v1/compress.
What are the tradeoffs?
Any compression can remove something the task needed. Extractive methods fail by omission, not by invention, which is easier to audit, but still a risk. Always test on your own tasks and compare bill per finished task rather than tokens saved. See extractive vs abstractive compression.
When should you use it?
Use it when single inputs are large and mostly irrelevant to the question: failing test output, build logs, large diffs, scraped pages, retrieved document chunks and MCP results. Skip it for short prompts, where there is little to save.
npm install -g supercompress-proxy && supercompress setup
Frequently asked questions
What is context compression?
It is reducing the amount of text sent to an LLM while keeping the parts the task needs, by methods such as truncation, summarization, pruning or extraction.
Is context compression the same as prompt compression?
They overlap. Prompt compression usually refers to a single prompt, while context compression for agents also covers tool output and history across steps.
Does context compression change the answer?
It can, if a needed line is dropped. Evaluate on your own tasks before relying on it.
What is query-aware compression?
Compression that depends on the question being asked, so different questions keep different parts of the same text.