What problem does it solve? Long-running AI agent sessions overflow limited context windows, driving up token costs, latency, and output quality degradation. This Skill provides concrete techniques and Python utilities to extend effective context capacity without switching to larger models. ## Core Features & Use Cases - Compaction & Summarization: Trigger category-aware summarization of tool outputs, conversation turns, and retrieved documents when utilization exceeds 70-80%. - Observation Masking: Replace verbose tool outputs with compact retrievable references using the ObservationStore class, achieving 60-80% reduction in masked content. - KV-Cache Optimization: Design stable prompt prefixes and measure cache hit rates to cut cost and latency on repeated requests. - Budget Management & Partitioning: Allocate token budgets per context category and split oversized tasks across sub-agents with isolated contexts. - Use Case: An agent loop processing hundreds of tool calls per session uses ContextBudget to detect 80% utilization, masks resolved observations, and compacts history before quality degrades. ## Quick Start Ask the AI to apply context optimization techniques to reduce token usage in an agent conversation that is approaching its context window limit.