Context Compression
Techniques for reducing the number of tokens in an AI agent's context window while preserving the essential information. Methods include summarizing long conversation histories, extracting key facts from retrieved documents, pruning irrelevant tool outputs, and using specialized compression models. Context compression enables agents to handle longer conversations and more complex tasks within token budget and context window limits—especially important for cost-sensitive production deployments.
Frequently asked questions
- Does context compression lose important information?
- It can. Aggressive compression risks dropping details the agent needs later. Best practice is to compress selectively: summarize old conversation turns but keep recent ones verbatim, extract key facts from documents but retain the source reference for citation, and never compress the system prompt.