CHAPTER 05 · Prompt Caching and Context Management · 7 / 8
Connecting to the bigger picture
Chapter 4 measured the problem; this chapter solves it. The apply_change_cache_safely pattern protects the prefix that Chapter 3's PromptBuilder carefully put first. The Compactor keeps the loop from Chapter 2 from ever hitting the window ceiling. Chapter 9's file-based memory is the third context-management move (external storage). And Chapter 11's subagents are arguably the best context tool of all: a subagent does noisy work in its own window and returns a tiny summary, so the main context never sees the mess.