Lv.1 0 XP

Context Optimization Strategies — Keeping the Window Efficient

Core 7 min +30 XP
💡
THE ANALOGY

A surgeon's tray during an operation. Not every tool from the hospital is on the tray — only what's needed for this procedure. The scrub nurse actively manages the tray, removing used instruments and keeping current ones accessible. Context optimization is that active tray management.

⚠️ EXAM TRAP — The Wrong Answer People Choose

Treating context management as a one-time setup rather than an ongoing process. For long-running agents, context must be actively managed throughout the session — not just at the start.

KEY POINTS
1 Tool result trimming: return summaries and key metrics to conversation, store full data externally.
2 Conversation compaction: /compact in Claude Code, or summary injection via API for agent sessions.
3 Subagent delegation: offload verbose exploration to Explore subagents — return only structured summary.
4 Scratchpad files: for long computations, write intermediate results to files rather than conversation.
5 Context budget allocation: reserve space for reasoning — don't let tool results consume >40% of window.