---
title: 'Prompt compression'
description: 'Reducing the tokens sent to a model while attempting to preserve the instructions, evidence, state, and relationships needed for the task.'
canonical_url: 'https://darkfactory.dev/glossary/prompt-compression'
markdown_url: 'https://darkfactory.dev/glossary/prompt-compression.md'
collection: glossary
date_published: '2026-08-05T00:00:00-04:00'
date_modified: '2026-08-26T00:00:00-04:00'
---

# Prompt compression


## Definition

Prompt compression reduces the tokens sent to a model while trying to preserve the information needed for the next action. The compressor may select passages, summarize history, remove tokens estimated to be low value, shorten tool output, or replace a sequence of attempts with the current artifact and unresolved failures.

The preservation target must be explicit. Task goals, standing constraints, source provenance, exceptions, current state, and known failures do not have equal redundancy. A summary that keeps the topic while dropping one negation or approval boundary can remain fluent and still be operationally wrong.

Huiqiang Jiang and colleagues' 2023 LLMLingua paper treated prompt compression as an optimization problem and used a smaller language model for token-level compression. It is one learned method, not the origin of shortening prompts.

Compaction introduces a state transition. The original context is replaced or bypassed, so the system needs tests for what survives. Zhiqi Wang and colleagues' 2026 COMPINT study found that several compactors frequently lost standing session constraints across long-context chat, agent, and research settings. Its models and compactors are perishable, but the evaluation method exposes a durable requirement: test retained behavior, not summary fluency alone.

For high-consequence constraints, deterministic storage and reinjection can be safer than asking a summary to remember everything. Compression can point to a durable artifact instead of paraphrasing it, provided the next context retrieves the artifact when needed.

## Distinguish it from nearby terms

Truncation drops content at a boundary. Summarization rewrites it. Selection keeps chosen passages unchanged. Prompt compression is the broader objective and may use any of these mechanisms. Prompt caching avoids recomputing a repeated prefix but does not shorten it.

## Check your understanding

A compacted session remembers the goal and recent files but loses a standing rule requiring approval before deployment. Which retention probe should have failed before the compacted state was accepted?

## Also called

context compression, prompt compaction

## Related terms

- [Context rot](https://darkfactory.dev/glossary/context-rot)
- [Context window](https://darkfactory.dev/glossary/context-window)
- [Context engineering](https://darkfactory.dev/glossary/context-engineering)
- [Prompt caching](https://darkfactory.dev/glossary/prompt-caching)
- [Token efficiency](https://darkfactory.dev/glossary/token-efficiency)
- [Working memory](https://darkfactory.dev/glossary/working-memory)

## Related factory areas

- [Context, memory, knowledge & skills](https://darkfactory.dev/factory/context-memory-skills)
- [Model selection, routing & budgets](https://darkfactory.dev/factory/model-routing-budgets)

## Evidence and further reading

- [LLMLingua: Compressing Prompts for Accelerated Inference of Large Language Models](https://arxiv.org/abs/2310.05736)
- [The Art of Loop Engineering: How to Build Agents That Improve Over Time](https://www.youtube.com/watch?v=jPPiZ22DY3g)
- [Lost in Compaction: Evaluating Side-Constraint Loss under Context Compaction](https://arxiv.org/abs/2608.11242)
