AI CodeOps

Context window

A context window is all the text a model can take into account for one response, the response included. What counts, and how AI CodeOps keeps steps small.

A context window is the amount of text, measured in tokens, that a language model can take into account when it produces a response, counting the response itself. It works like the model's working memory for one request.

What it is

Everything in a request counts toward it: the system prompt, every message including tool results, images and documents, the tool definitions, and the output the model generates, including any thinking. Anthropic's context window guide lists the sizes per model; current Claude models range from 200,000 to 1 million tokens.

If the input alone is larger than the window, the request is rejected. Agents that run long loops manage the window by shortening tool results, clearing old ones, or summarising earlier turns.

Why it matters

Coding agents fill windows fast: source files, diffs, test output and tool results add up. A full window costs money on every call, and Anthropic notes that accuracy and recall degrade as the token count grows.

In AI CodeOps

A session doesn't carry one long chat from step to step. Each step starts with its agent's instructions, the task, and capped context:

repository context    a pack of about 32,000 bytes, 12,000 at most per file
earlier steps         up to 4,000 characters each, 24,000 in total
MCP tool result       shortened to 8,000 characters
tool results          the tool loop stops after 64,000 bytes in a step

Within a step, the messages of its tool loop accumulate, which is where prompt caching helps.

Frequently asked questions

Is a bigger context window always better?

No. Every token in the window is billed as input, and models can get worse at recalling details as the context grows. What goes in matters as much as how much fits.

Does prompt caching free up space in the window?

No. Cached tokens still count toward the window. Caching changes what you pay for them, not whether they count.