Context Window — максимальное число токенов (input + output), которое LLM может обработать за один вызов. 2026: Claude Opus 4.7 — 1M (200k stable), Gemini 2.5 — 2M, GPT-5 — 1M, Llama 3 — 128k-1M. 1 token ≈ 0.75 слова. 1M tokens ≈ 750k слов ≈ весь Harry Potter × 4 книги. Trade-off: больше context = больше стоимость + slower + potential "lost in the middle".
Ниже: подробности, пример, смежные термины, FAQ.
# Claude 1M context in Claude Agent SDK
from anthropic import Anthropic
client = Anthropic()
# Full codebase в context
with open('codebase.txt') as f:
codebase = f.read() # 500k tokens
response = client.messages.create(
model='claude-opus-4-7[1m]', # 1M context variant
max_tokens=4096,
system='You review code.',
messages=[{'role':'user','content':f'Review:
{codebase}'}]
)RAG: cheaper, extensible к infinite data, but lose semantics на chunk boundaries. Long context: simpler код, but $$ cost + latency. Hybrid обычно best.
Для code review whole repo, book summary, long document analysis — да. Для chat — 32k-200k достаточно.
Prompt caching: 10× cheaper для repeat prefixes. Streaming для UX. Только необходимый context — not whole history.