02Chapter 2: Tokens and budgeting the windowThis chapter assumes you have called a language model through a chat or API interface and know what a system prompt is. You should also be able to read short Python functions. The previous chapter introduced the context window as the fixed amount of text a model can consider on one call. This chapte6 min read
03Chapter 3: The parts of a contextEvery model call receives one block of input, and that block is assembled from distinct parts. This chapter names those parts and describes what each one costs and how it changes during a session. It also explains who controls each part and where each one tends to cause trouble. It assumes you have 7 min read
04Chapter 4: Choosing what to include and what to leave outThis chapter assumes you have called a language model through an API, know what a system prompt is, and can read short Python. It also assumes you know the token budget from the earlier chapter. The question here is which items deserve the tokens you have.6 min read
05Chapter 5: How context goes wrongThis chapter assumes you know what a context window is, how tokens are counted, and what the parts of a context are (system prompt, tools, history, retrieved data, user input). It also assumes you can read short Python. Here you will learn four named failure modes, how to recognize each in model out7 min read
06Chapter 6: Where to put things in the contextThis chapter assumes you have read the earlier chapters on token budgets, the parts of a context, and context failures. It also assumes you can read short Python. Once you have decided what goes into the window, you still have to decide where each piece goes. Models do not read every position equall7 min read
07Chapter 7: Retrieval and loading data just in timeThis chapter assumes you have read the earlier chapters on token budgets and on the parts of a context. You should be comfortable reading short Python. You do not need a vector database or any particular library. The examples use only the standard library.6 min read
08Chapter 8: Tool definitions and tool resultsThis chapter covers how tool definitions and tool results use up context, and how to keep both small. It assumes you have called a model with tool use (function calling) at least once. It also assumes you know what a token is and can read short Python.6 min read
09Chapter 9: Trimming and managing conversation historyConversation history is the part of the context that grows on every turn. The system prompt and tool definitions stay about the same size. History gets longer with each exchange, so it is usually the first part to push a long session past its token budget. This chapter covers how to decide what hist6 min read
10Chapter 10: Compacting and summarizing long sessionsThis chapter assumes you know what a token budget is, how the parts of a context fit together, and how to trim conversation history. It also assumes you can read short Python functions. Trimming drops old messages. Compaction replaces them with something shorter that keeps what matters. Done well, i6 min read
11Chapter 11: Memory and notes outside the windowYou should have read the chapters on the token budget, retrieval and just-in-time loading, and compaction. You should be comfortable reading short Python programs. This chapter covers what to do with information that must outlive a single context window, or that does not deserve a permanent place in6 min read
12Chapter 12: Splitting work across subagents with separate contextsThis chapter assumes you have read the earlier chapters on the parts of a context, token budgets, tool results, and compaction. You should be comfortable with the idea that every model call sees only what you put in its window.6 min read
13Chapter 13: Structuring prompts for cachingThis chapter assumes you can call a language model through an API, know what a system prompt is, and can read short Python. It covers how to order a prompt so a provider can reuse work from earlier calls.7 min read
14Chapter 14: Measuring whether a context change helpedThis chapter assumes you have called a model through an API, you know what a system prompt and a token are, and you can read short Python. You should also have seen the earlier techniques in this tutorial: selection, trimming, compaction, retrieval, and caching. Each one is a context change. This ch7 min read