Cheat sheet
Context window
Compressed facts from lesson 0002. Print this after the labs, not instead of them.
What it is
- The maximum token sequence the model conditions on in one call. Karpathy: RAM. Anthropic: attention budget.
- Shared by system, history, tools/files, and the output you still need to generate. Overflow → API error.
- Counted in that model’s tokenizer, not words. Token cheat sheet.
Two failure modes
- Hard: over the cap. Rejected.
- Soft: under the cap, but context rot (recall fades as n grows) and the U-curve (middle facts weaker than start/end). Anthropic; Liu et al.
A receipt, not a vibe
- OpenAI cookbook:
"tiktoken is great!"→ 6 tokens oncl100k_base(IDs 83, 8251, 2488, 382, 2212, 0). - Same word, different encodings:
antidisestablishmentarianismis 5 tokens on r50k/p50k and 6 on cl100k/o200k. - Chat messages add wrapping tokens;
max_tokensreserves output inside the same window.
Why later patterns exist
- Smallest high-signal token set — the seed of context engineering.
- RAG, skills, evict · compact · note, sub-agents: ways to page RAM to disk instead of stuffing the window. Context engineering card.