Skip to main content

Overview

The CompressionManager automatically compresses verbose tool results when the context grows too large, keeping your agent within its context window limits while preserving key information.

Quick Start

Custom Configuration

Configuration Options

How It Works

  1. Threshold Detection: After each tool result, the manager checks if compression is needed (count-based or token-based)
  2. Selective Compression: Only tool results over 200 characters are compressed — short results pass through unchanged
  3. Parallel Compression: Multiple tool results are compressed concurrently for speed
  4. Fact Preservation: The built-in prompt preserves numbers, dates, IDs, URLs, and proper nouns

Integration with Loop Hooks

CompressionManager integrates via the beforeLLMCall loop hook. It runs before the existing ContextCompactor, giving you layered context management:
  1. Compression (summarize individual tool results)
  2. Compaction (trim overall context if still too large)
  3. User hooks (custom transformations)