Claude Cookbook Publishes Three-Primitive Context Engineering System: Compaction at 150K Tokens, Tool Clearing at 30K, Persistent Memory — With Production Config Examples
Anthropic's Claude Cookbook published a comprehensive context engineering guide covering three API-level primitives: server-side compaction (triggers at configurable token thresholds, distills conversations to summaries), tool-result clearing (replaces bulky tool outputs with '[cleared]' placeholders at zero inference cost), and persistent memory (cross-session file-based storage the model manages itself). A research agent benchmark showed these three primitives together reduced peak context from 335K tokens to a sustained 50-80K range with cross-session persistence. The diagnostic framework: if >80% of context is re-fetchable tool output, use clearing first; if long dialogue accumulates, add compaction; if work spans sessions, add memory.
↳ Follow the thread