liveBook · Manning

Compression

As explained in Context Engineering

The process of representing information with fewer bits or tokens while retaining relevant information.

Compression reduces the active context of an LLM or agent by replacing or removing detail while preserving what is needed to continue the task. Protect information that is difficult to reconstruct, including instructions, user constraints, decisions, tool schemas, identifiers, file paths, errors, and current task state. section 7.4.1

Use context writing before compression: move useful material to external storage so the agent can retrieve it later. Compression is lossy; applying it before writing can permanently discard recoverable state. section 7.3

Three techniques reduce active context in different ways:

  • Summarization rewrites history, tool outputs, or phase results into a shorter representation. Use explicit fields for intent, decisions, artifacts, current state, open issues, and next steps so omissions are easier to see. section 7.4.2 section 7.4.1
  • Trimming removes content without rewriting it, such as old tool observations or low-value intermediate reasoning. It is cheaper and more predictable than summarization, but deleted details are lost unless they can be retrieved elsewhere. section 7.4.2
  • Observation masking replaces a bulky tool result in the active prompt with a concise summary and storage pointer. Keep recent observations, unresolved errors, and evidence needed for active reasoning; mask duplicate outputs, boilerplate, and resolved logs first. Without the external write, masking is lossy deletion. section 7.4.2

For long sessions, summarize only the newly removed span and merge it into a persistent summary rather than repeatedly rewriting the full history. Deduplicate stable facts and preserve identifiers verbatim. This limits summary drift and preserves the artifact trail. section 7.4.1 section 7.4.2

Trigger compression explicitly, using a threshold above the offloading threshold, a sliding window, a task boundary, or the importance of context spans. Evaluate it by whether the task can continue: probe factual recall, artifact state, the current plan, decision rationale, and instruction adherence. Textual similarity alone can miss a critical omission. section 7.4.1

After a token-heavy search

After a search tool returns a large result, summarize the relevant findings and retain a pointer to the stored output. Leave evidence needed for active reasoning unmasked, and carry the current task state and next steps into the active context. section 7.4.2

How Context Engineering covers it

How deep it goes
Details techniques, triggering rules, preservation priorities, and functional evaluation probes.
Examples
Uses token-heavy search results and bulky tool observations to illustrate summarization and masking.
What you can do after
Evaluate compression by probing recall, artifact state, plans, decision rationale, and instruction adherence rather than relying on textual similarity.
How it connects
Connects compression to context writing, summarization, retrieval, and context-window management.

Also explained in

Compare how 15 books explain compression →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Context Engineering. The section links point to the parts of the book it draws on.