Budgeting the Context Window: Compaction, Retrieval and Memory for Agents
Treat the context window like memory in a constrained system: allocate it, measure it and reclaim it. A per-component budget, a compaction policy that runs in code, just-in-time retrieval, and when to hand work to a sub-agent with a clean context.
Read Article