Prompt Compression

What is Prompt Compression?

Prompt compression is the practice of reducing the number of tokens in prompts sent to a language model, by removing, shortening or summarizing content, while keeping the information the model needs.

Updated November 2026 · 2 min read


Prompt compression is the practice of reducing the number of tokens sent to a language model while keeping the information it needs to do the job. Prompts grow over time. Instructions accumulate, examples are added, retrieved documents get longer and conversation history piles up. Since every input token is billed and processed on every request, trimming prompts lowers cost and speeds up responses. Done carelessly, it also removes information the model needed.

Prompt compression techniques

  • Editing instructions: removing repetition, outdated rules and verbose phrasing. Often the easiest win, since system prompts tend to grow unchecked.
  • Fewer examples: keeping only examples that measurably improve results.
  • Better retrieval: sending the most relevant passages rather than whole documents. See retrieval-augmented generation.
  • Summarizing history: replacing older conversation turns with a short summary.
  • Trimming tool results: passing only the fields an agent needs from large API or database responses.
  • Removing formatting overhead, such as unnecessary whitespace, HTML or repeated headers.
  • Automated compression: research methods, such as Microsoft's LLMLingua, use a small model to remove less important tokens from a prompt.

Prompt compression vs. prompt caching

If content is identical across requests, prompt caching may save more than compressing it, with no risk to quality. Compression matters most for content that changes with each request, such as retrieved documents, tool results and conversation history. In practice, teams use both.

An example

Consider a hypothetical agent that helps sales staff prepare for calls by pulling data from the CRM, recent emails and news. Each run sends about 30,000 tokens to the model. A review shows that CRM records include every field, most irrelevant; emails include full quoted threads and signatures; and news results include whole articles. The team limits CRM data to 15 relevant fields, strips quoted text and signatures from emails and sends only article headlines and first paragraphs. Average input falls to about 7,000 tokens, a reduction of roughly 77%. In side-by-side reviews of 200 briefings, sales staff rate the compressed versions as equally useful and slightly more focused.

Common pitfalls

  • Cutting without testing. See AI evaluation.
  • Removing context that prevents errors, leading to retries that cost more than the savings.
  • Compressing cached content, which can break caching and raise costs.

Prompt compression is part of context engineering and a common technique in AI cost optimization.

Frequently asked questions

What are the most common ways to do prompt compression?

The easiest prompt compression win is usually editing system prompts to remove repetition, outdated rules and wordy phrasing. Teams also keep only examples that measurably help, retrieve the most relevant passages instead of whole documents, summarize older conversation turns and pass only the fields an agent needs from tool results. Research methods such as Microsoft's LLMLingua automate token removal.

Should you use prompt compression or prompt caching?

Most teams use both, for different content. When content is identical across requests, prompt caching usually saves more than compression and carries no quality risk. Prompt compression pays off most on content that changes with each request, such as retrieved documents, tool results and conversation history. Compressing cached content can break the cache and raise costs.

Does prompt compression hurt the quality of model responses?

It can if it removes context the model relies on, which leads to errors and retries that may cost more than the tokens saved. Test compressed prompts against the originals on real tasks before rolling them out. Careful, targeted prompt compression often leaves quality unchanged, and trimming irrelevant material can make outputs more focused.