Protocol

Compact context by preserving decisions and unresolved work—not every tool result

Compaction should save the project, not the transcript.

When it fits

  • A long context contains large raw tool outputs and repeated discussion that crowd out current task state.

When to avoid it

  • Over-aggressive compaction can silently remove a detail that matters later; favor recall before token efficiency.

Why it matters

When context must be compressed, preserve architectural decisions, constraints, unresolved bugs/questions, current state, source/artifact references and next actions. Drop duplicated prose and old raw tool results once their useful facts are represented elsewhere. Start with high recall; trim only after testing complex traces.

Steps

  1. Keep decisions and their reasons.
  2. Keep unresolved items and next actions.
  3. Keep references to authoritative artifacts/sources.
  4. Remove redundant raw tool outputs already reflected in durable state.
  5. Test compaction on difficult long traces before aggressive shortening.

An example

Keep 'migration uses option B because rollback is required' and the source file path; drop the 2,000-line raw search result that led there.

Check your result

A fresh context can continue the task without reopening decisions or inventing missing constraints.

Keep this limit in mind

  • Over-aggressive compaction can silently remove a detail that matters later; favor recall before token efficiency.

Connected ideas

Useful with
Version the configuration that changes behavior

Evidence and sources

Supports

Anthropic recommends compaction that preserves key decisions, unresolved work and implementation details while removing redundant tool outputs.

Over-aggressive compaction can silently remove a detail that matters later; favor recall before token efficiency.

Effective context engineering for AI agents · See source record

All sources (1)