A model may accept an entire repository in one prompt yet miss a critical instruction inside it. Its context window is the finite amount of information it can take in and process at once, usually measured in tokens. The advertised limit is not a guarantee that the model will reliably use everything within it. section 3.4 section 3.4.1
Too little context invites invented interfaces and generic fixes; too much can bury relevant information or make the model fixate on unrelated files. Stale or incorrect inputs can also poison an otherwise carefully assembled prompt. Context engineering addresses the selection, structure, order, and maintenance of inputs—not just their volume. section 3.0 section 3.1 section 3.3
The effective context window is the length at which a model still reliably uses the information it receives. In one LongCodeBench evaluation, a model’s code-comprehension score fell from 29% at 32,000 tokens to 3% at 256,000, even though the answer was present at both lengths. Other models degraded less sharply. Larger inputs also increase latency, memory pressure, and inference expense. section 3.4.1
Manage the window as a working budget:
- Select relevant, current inputs rather than attaching an entire project by default. Label examples and explain their roles so the model does not have to infer their relationships. section 3.2.2 section 3.3
- Load procedures progressively: expose skill descriptions first, load the relevant instructions when needed, and retrieve referenced files only when the task reaches them. section 3.3.6
- Maintain an explicit plan or to-do list during long sessions. Refreshing the plan in context can keep goals visible without replaying the entire interaction. section 3.5.2
- Inspect tool overhead. MCP tool definitions can consume substantial space before the conversation starts; consider CLI alternatives where they provide the needed functionality without persistent schema overhead. section 9.5.1
- Set input limits separately from output limits. A request setting that caps generated tokens does not, by itself, cap the incoming prompt. section 6.2
Table 9.6 Context Usage claude-sonnet-4-5
|
Source
|
Tokens
|
Share
|
|
System prompt
|
3,900 tokens
|
2%
|
|
MCP tools
|
58,400 tokens
|
29%
|
|
Memory files
|
1,200 tokens
|
1%
|
|
Messages
|
42,000 tokens
|
21%
|
|
Free space
|
94,500 tokens
|
47%
|
This session breakdown shows how tool definitions and messages compete for the same finite space. section 9.5.1
Measure context against quality and cost
For text-to-SQL generation, compare prompts containing zero, one, two, five, ten, and twenty example queries. In one benchmark, median SQL overlap similarity for simple queries rose from about 0.46 with no examples to 0.71 with twenty, while the measured cost also increased. Ten examples offered a better accuracy-to-cost tradeoff in that run; the result is a measurement for that workload, not a universal setting. Keep examples in a separate frozen pool and exclude the current test answer to avoid inflating results. section 6.4 section 6.4.1 section 6.4.2





































