"इसमें million-token context window है" ऐसे throw around किया जाता है जैसे यह सब कुछ solve कर देता है। यह नहीं करता। मैंने इसे धीरे-धीरे सीखा, एक पूरे codebase को एक Claude call में ठूँसकर और देखते हुए कि agent बेहतर नहीं, बदतर हो गया। ज़्यादा context मुफ्त नहीं है, और हमेशा बेहतर भी नहीं है। मुझे explain करने दें कि context window actually क्या है और बड़ी संख्या कब आपकी मदद करती है बनाम कब नुकसान।
Window actually क्या है
Context window वो maximum tokens की संख्या है जिसे model एक request में attend कर सकता है — वह सब जो आप भेजते हैं (system prompt, tools, full message history, files) plus जो वो generate करता है। Current Claude models पर input window बड़ी है: Opus 4.6, 4.7, और 4.8 सभी 1M-token context चलाते हैं, Sonnet 4.6 भी 1M है, और Haiku 4.5 200K है। Output अलग से capped है — Opus models पर 128K tokens तक, Sonnet और Haiku पर 64K।
ध्यान दें वे दो अलग limits हैं। Input limit hit होने पर आपको stop_reason: "model_context_window_exceeded" मिलता है। Requested output cap hit होने पर आपको stop_reason: "max_tokens" मिलता है। उनका अलग-अलग मतलब है और अलग-अलग fixes चाहिए, इसलिए दोनों branches handle करें। लोग इन्हें हमेशा mix करते हैं और फिर wonder करते हैं कि max_tokens बढ़ाने से क्यों help नहीं हुई — क्योंकि problem input side पर थी।
Token एक word क्यों नहीं है
Quick mechanism check, क्योंकि यह budgeting के लिए matter करता है। Model words नहीं देखता; वो tokens देखता है, जो tokenizer द्वारा produce किए गए sub-word chunks हैं। English prose roughly तीन-चौथाई words per token चलती है। Code ज़्यादा dense tokenize होता है। Non-English text और भी dense।
जिसका मतलब है आप Claude के token counts का estimate tiktoken से नहीं कर सकते — यह OpenAI का tokenizer है, और यह plain text पर Claude को 15-20% undercounts करता है और code पर और भी ज़्यादा। अगर आपको real number चाहिए, उसी model ID के साथ count_tokens endpoint call करें जिस पर आप inference run करेंगे। Tokenizers model-specific हैं। Opus 4.8 और Fable 5 एक share करते हैं; पुराने models अलग count करते हैं। Wrong model पर measure किया budget reuse न करें।
वो part जिसके बारे में कोई warn नहीं करता: window भरने से quality degrade होती है
यहाँ counterintuitive bit है। सिर्फ इसलिए कि आप कर सकते हैं million tokens डालना इसका मतलब नहीं आपको करना चाहिए। Models बहुत लंबे context के middle में buried information पर कम reliably attend करते हैं, और noisy context उस signal को dilute करता है जो model को current step के लिए चाहिए। मैंने देखा है एक clean 20K-token context वाला agent उसी task पर 400K tokens वाले same agent से better perform करे, क्योंकि 400K पर, 95% वो था जिस पर वो attend कर रहा था वो बारह steps पहले का stale tool output था।
तो लक्ष्य यह नहीं है कि आप कितना stuff ठूँसते हैं उसे maximize करें। लक्ष्य है context को relevant रखना। Million-token ceiling genuinely बड़े single inputs के लिए safety margin है — पूरा repo जिसे एक बार analyze करना है, एक long document, एक deep research trace। यह license नहीं है कभी cleanup न करने की।
Context को relevant रखने के तीन tools
ये अलग-अलग problems solve करते हैं; जो गड़बड़ है उसके हिसाब से choose करें।
Context editing prune करता है। यह आपके set threshold के आधार पर transcript से stale tool results और thinking blocks clear करता है। Clear किया गया content remove होता है, replace नहीं। इसका use तब करें जब पुरानी tool outputs dead weight हैं और आप conversation structure खोए बिना lean transcript चाहते हैं। Long loops में tool-call accuracy high रखने के लिए यह सही call है।
Compaction summarize करता है। जैसे-जैसे conversation window limit के पास आती है, API earlier history को server-side summary block में condense करता है। इसका use तब करें जब आप genuinely ceiling hit करने वाले हैं और आगे जाना है। एक critical gotcha: आपको हर turn में पूरा response.content वापस अपने messages में append करना होगा — compaction blocks वहाँ रहते हैं, और अगर आप केवल text extract करके वो append करते हैं, तो आप silently compaction state खो देते हैं और पूरी चीज़ टूट जाती है।
Memory sessions के पार persist करती है। दूसरे दोनों एक conversation के अंदर operate करते हैं; memory वो files हैं जो agent read और write करता है जो process restart के बाद भी survive करती हैं। जब state session के पार रहनी हो — preferences, accumulated learnings, एक running scratchpad — वो memory है, context नहीं। और honestly, Opus 4.8 जैसे models noticeably better perform करते हैं जब आप उन्हें चीज़ें लिखने की जगह देते हैं और उन्हें अगली बार check करने के लिए कहते हैं।
बहुत से long-running agents तीनों use करते हैं। Editing dead turns को prune करता है, compaction ceiling के पास आपको catch करता है, memory runs के बीच जो matter करता है उसे hold करती है।
एक budgeting heuristic जो मेरे काम आई है
अपने context को तीन zones वाला सोचें। Frozen prefix (system prompt, tools) — इसे stable रखें, यह कभी नहीं बदलता, और bonus में यह cache होता है। Working set — recent turns जिन्हें model actually current step के लिए चाहिए। और tail — current question या tool result। जब working set उन चीज़ों से भरने लगे जिन्हें model ने कई turns में reference नहीं किया, यह आपका cue है edit या compact करने का। किसी token number पर नहीं। जब relevance गिरे तब।
एक और practical note: large outputs। अगर आप Opus model पर 128K output ceiling के करीब कुछ माँगते हैं, आपको request stream करना होगा। Non-streaming calls high max_tokens पर SDK HTTP timeouts hit करती हैं — request बस wait करते-करते मर जाती है। Streaming helper use करें और उससे final message pull करें।
Million-token window एक real capability है और कभी-कभी exactly वही जो आपको चाहिए। लेकिन skill उसे fill करने में नहीं है। Skill यह जानने में है कि कब एक tight, relevant 30K context एक bloated 600K को beat करेगा — जो, agents build करने के मेरे experience में, ज़्यादातर समय होता है।
