CHAPTER 04 · Tokens, Context Windows, and the Quadratic Problem · 5 / 6
Connecting to the bigger picture
Chapter 3 built the prompt; this chapter measures it and explains why it cannot grow forever. Chapter 5 attacks the problem from both sides: caching to tame the cost curve, and compaction to stay under the window ceiling. The estimate_tokens and CostModel you wrote here become the capstone's budget meter, the thing Chapter 12 wires into a real kill switch.