Editor's note: This is an AI-assisted English adaptation of the Context series finale. The original used a 200K-token window as its example; actual limits depend on the model and setup.
Start a Claude Code session, ask it to read a file, then ask a follow-up. The next model call needs more than the new question. It may need the earlier request, the file excerpt, your project instructions, and the definitions of tools it can call. Ask enough follow-ups and the runtime has to decide which of those details to keep, summarize, or fetch again.
The previous articles followed those decisions one at a time. This finale puts them together: how does Claude Code give the model enough information to act without rebuilding every part of the prompt from scratch or carrying every token forever?
1. The context window is a per-request budget
A 200K-token window is not a lifetime allowance for the session, and it isn't 200K tokens of user text. Tool definitions, system instructions, messages, and generated output all compete for room. Some Claude models have a larger window; see the Claude API context window guide for current limits.
The Messages API takes the relevant conversation with each request. A long-lived session is the runtime's abstraction: it decides what the next call needs to see. A summary can replace older turns, and a cached prefix can reduce the work of processing repeated input. Neither means the model keeps a private, growing copy of the session. Part 1 shows what goes into the request.
2. Message history has structure you can't trim away
A conversation isn't a flat text log. When the assistant requests a client-side tool call, the result must refer back to that call. In the following user message, results come before any text. The tool-call guide documents the pairing and ordering rules. The Messages API reference clarifies a separate point: consecutive entries with the same role are combined into one turn, so strict alternation isn't a rule for each entry in the raw array.
That distinction matters on interruption, compaction, or rewind. For instance, keeping an assistant tool call while discarding its corresponding result can leave the next request invalid. Cutting history at sensible boundaries is as important as cutting its size. See Part 2 for the series' account of how the runtime keeps related messages together.
3. Prompt caching shapes the request
The Claude API's prompt cache matches a prefix in the order tools, system, messages. If a tool definition near the beginning changes, repeating the same conversation afterward won't restore a match across that change. If the runtime adds a new message after a stable prefix, that prefix may still be reusable.
Caching doesn't give the model a bigger window. It changes the cost of processing input that would otherwise be repeated. That's why ordering is an architectural choice, not just an optimization to turn on at the end. Part 3 takes that idea through several concrete cases.
4. Put stable information early and changing information late
A project rule can be a standing instruction without belonging in the most stable part of the prompt. Consider “use pnpm in this repository.” It should influence the model's choices, but it can change with the project. In the implementation examined in Part 5, project instructions could travel with conversation context rather than being baked into the base system prompt. That gives the runtime a way to supply them without changing an earlier stable prefix.
The exact placement is an implementation observation, not an API guarantee. The current Claude Code memory guide documents which instruction files load and when. For caching, the useful question is where the first change appears relative to the prefix you're trying to reuse.
5. The same meaning doesn't make the same prefix
Two requests can tell the model essentially the same thing while presenting different input for the cache to match. A skill catalog may gain one entry. An MCP server may connect after startup. The date may roll over. Rewriting a whole early block for any of these updates creates a different prefix, even if most of the old text still means the same thing.
There are two ways to avoid unnecessary work: register just the change, or defer the details until they're needed. Claude Code's MCP tool search illustrates the latter: discovering a tool and loading its definition don't have to happen at session startup. An update still costs context when it arrives; a cache-friendly layout only limits how much prior input it disturbs.
6. A system reminder carries information; it doesn't make decisions
A tool may return an excerpt while the runtime also needs to say that the file changed outside the session. Or the runtime may simply need to report a new date. In the version studied in Part 7, several such updates used the same <system-reminder> label. It distinguishes runtime-supplied text from what the human typed, but it isn't a new API role or an authorization mechanism.
The component that detects a change is separate from the channel that reports it. So is the component that decides whether an action is allowed. The reminder can tell the model that a file changed; it doesn't decide what to edit.
7. Context management is distributed, but the constraints are shared
Compaction and delegation solve different problems. Compaction replaces older detail with a smaller account of the work; the context window guide lists what the current client reloads separately. A regular, non-forked subagent can do an investigation in its own window and return findings instead of sending every file it read back to the parent. Part 6 explains the limits of that isolation.
You don't need to assume one component owns every decision. Compaction, delegation, and tool discovery manage different kinds of information. They face the same constraints: fit the model's window, protect useful cache prefixes, and leave valid message history for the next call.
Context organizes information; the loop makes things happen
This series tracked what the model sees, where it comes from, and how it survives the next turn. The Agent Loop finale follows the other half: when the runtime calls the model, runs tools, handles failures, and decides to stop. The Tools series' Agent chapter shows where those two concerns meet in one tool.
Put them together and a file read is more than an action: its result enters a structured history, shares a budget with everything else the model sees, and may later be summarized or fetched again. That's the case for calling Claude Code a cache-first information system. Before adding another mechanism, ask what the next request needs to know, how often that fact changes, and what it costs to keep it around.
Top comments (0)