Module 1 · Spending less on the same work · Lesson 3
Trimming and compacting context
The four ways to send fewer tokens (select, clear, compact, compress), how each one interacts with the prompt cache, and the break-even arithmetic that tells you when trimming saves money and when it costs more.
By the end of this lesson you can
- Distinguish selecting, clearing, compacting and compressing context, and name the cost and quality risk of each
- Derive how many further steps a context edit needs before it pays back under caching, and apply it to tool-result clearing
- Configure tool-result clearing and server-side compaction on the Claude API, and account for compaction in usage tracking
- Compare trimming policies for a long-running agent with and without caching, and explain why aggressive trimming can raise cost