Anatomy of the Window
≈ budgetSystem Prompt
Stable identity & rules — keep it short, keep it cacheable
Tool Definitions
Only the tools this task needs — not the whole catalog
Retrieved Knowledge
Top-k, reranked, deduplicated — relevance beats volume
Memory
Durable facts & preferences worth carrying across sessions
Conversation History
Recent turns verbatim, older turns compacted to summaries
Current Request + Headroom
The actual task — plus room left for the model to think & answer
Percentages are a discipline, not a law — the point is that every token in is a token someone chose.
Write
Persist what matters outside the window: scratchpads, notes, long-term memory. Don't make the model re-derive what it already figured out.
Example: agent writes progress notes to a file between steps
Select
Pull in only what this turn needs: RAG for knowledge, memory lookup for facts, just-in-time tool loading for capabilities.
Example: load 3 relevant tools, not all 40
Compress
Summarize old history, trim tool outputs, compact aggressively as the session grows. Recent stays verbatim; ancient becomes a summary.
Example: compact turns 1–40 into one paragraph, keep 41–50 raw
Isolate
Delegate noisy work to subagents with their own windows. The searcher reads 100 files; the main thread gets one clean answer back.
Example: research subagent returns findings, not transcripts
The four operations — write, select, compress, isolate — are how you spend the budget on purpose.