Skip to contentমূল লেখায় যান

Topic 03 · AI harnessesটপিক 03 · AI harnesses

Context Management

What the model sees comes from your instructions, the conversation, and the tool results. When the window fills up, the harness compacts the older messages, and your instructions decide what stays.

4 min read4 মিনিটে পড়া যায় · 5 sections5টি সেকশন · 4 sources4টি সোর্স · updated Nov 2026আপডেট: Nov 2026

The window fills, then compactsউইন্ডো ভরে, তারপর compaction হয়

Fill the window with a chat and watch compaction swap old messages for a summary. Then see which rule survives.চ্যাট দিয়ে উইন্ডো ভরুন আর দেখুন compaction পুরোনো মেসেজের জায়গায় একটা সারসংক্ষেপ বসায়। তারপর দেখুন কোন নিয়মটা টিকে থাকে।

2 min2 মিনিট8 steps8টি ধাপ
  • Window usedউইন্ডো ব্যবহৃত3 %
  • Rules keptরাখা নিয়ম1 / 1
context window · 1M tokensকনটেক্সট উইন্ডো · 1M টোকেনused 3%ব্যবহৃত 3%compacts at 90%কম্প্যাক্ট: 90%System 15kসিস্টেম 15kCLAUDE.md 5kCLAUDE.md 5kChat 5kচ্যাট 5k5k5k5k5kChatচ্যাট+ tools+ টুলrule: use tabsনিয়ম: use tabsCLAUDE.mdCLAUDE.md ফাইলno rule hereএখানে নিয়ম নেইModelমডেলsees 25k tokensদেখে 25k টোকেন

You’ll learnআপনি শিখবেন

  • What counts toward the context windowকনটেক্সট উইন্ডোতে কী কী গোনা হয়
  • What compaction does to old messagescompaction পুরোনো মেসেজের সঙ্গে কী করে
  • Why a rule only in the chat can be lostশুধু চ্যাটের নিয়ম কেন হারাতে পারে
  • Why rules belong in CLAUDE.mdনিয়ম কেন CLAUDE.md-তে রাখবেন

What the context window holds

The Messages API is stateless: you always send the full conversation history Source 4সোর্স 4. So the model has no memory between two requests. It sees only what the harness sends in the request. The API docs say that everything in the request counts toward the context window: the system prompt, every message (with tool results, images, and documents), and the tool definitions Source 2সোর্স 2. The docs call the context window the "working memory" of the model Source 2সোর্স 2.

In Claude Code, the context window holds the conversation history, file contents, command outputs, CLAUDE.md, auto memory, loaded skills, and system instructions Source 1সোর্স 1. Claude sees the skill descriptions at session start, but the full content of a skill loads only when Claude uses it Source 1সোর্স 1.

The window has a size limit. It holds up to 1M tokens, depending on the model Source 2সোর্স 2. A bigger window is not always better: as the token count grows, accuracy and recall degrade. The docs call this context rot Source 2সোর্স 2.

সহজ English

The model does not remember earlier requests. It only sees what the harness sends to it each time Source 4সোর্স 4. Everything in the request counts: the instructions, every message, the tool results, and the tool descriptions Source 2সোর্স 2. Think of the context window as the "working memory" of the model Source 2সোর্স 2.

In Claude Code, this memory holds the chat, the files that Claude read, the command outputs, CLAUDE.md, the loaded skills, and the system instructions Source 1সোর্স 1.

The window has a limit, up to 1M tokens on some models Source 2সোর্স 2. More text is not always better. When the window gets very full, the model gets less accurate. This is called context rot Source 2সোর্স 2.

বাংলা ব্যাখ্যা

মডেল আগের রিকোয়েস্টগুলো মনে রাখে না। harness প্রতিবার যা পাঠায়, সে শুধু সেটাই দেখে Source 4সোর্স 4। রিকোয়েস্টের সবকিছুই গোনা হয়: system prompt, প্রতিটা মেসেজ, tool result আর tool definition Source 2সোর্স 2। context window-কে মডেলের "working memory" ভাবতে পারেন Source 2সোর্স 2।

Claude Code-এ এই মেমরিতে থাকে চ্যাট, Claude যেসব ফাইল পড়েছে, কমান্ডের আউটপুট, CLAUDE.md, লোড করা skill আর system instructions Source 1সোর্স 1।

উইন্ডোর একটা লিমিট আছে, কিছু মডেলে 1M টোকেন পর্যন্ত Source 2সোর্স 2। বেশি টেক্সট সবসময় ভালো না। উইন্ডো খুব ভরে গেলে মডেলের নির্ভুলতা কমে যায়। একে বলে context rot Source 2সোর্স 2।

When the window fills up

Claude Code manages the context automatically when it comes near the limit. It compacts the conversation into a summary Source 1সোর্স 1. The summary keeps your requests and the key code snippets, but detailed instructions from early in the conversation can be lost Source 1সোর্স 1. If one file or tool output is so large that the context fills again right after each summary, Claude Code stops auto-compacting after a few attempts and shows an error. It does not loop Source 1সোর্স 1.

Available: [Policy] [Instructions] [Old chat]
                 │                     │
                 │              compacted to a summary
                 ▼                     ▼
This step: [Policy] [Instructions] [Summary] ──► Model

You control what stays Source 1সোর্স 1:

  • Put the rules that must stay in CLAUDE.md, not only in the conversation.
  • Add a "Compact Instructions" section to CLAUDE.md.
  • Run /compact with a focus, for example /compact focus on the API changes.
  • Run /context to see what uses the space.

সহজ English

When the window is nearly full, Claude Code makes a summary of the conversation and uses the summary in place of the old messages Source 1সোর্স 1. This is called compaction. The summary keeps your requests and the important code. Detailed instructions from the start of the chat can get lost Source 1সোর্স 1.

So keep important rules in CLAUDE.md, not only in the chat Source 1সোর্স 1. You can also tell Claude what to keep: run /compact with a focus, for example /compact focus on the API changes. To see what fills the window, run /context Source 1সোর্স 1.

বাংলা ব্যাখ্যা

উইন্ডো প্রায় ভরে গেলে Claude Code কথোপকথনের একটা সারসংক্ষেপ বানায় আর পুরোনো মেসেজের জায়গায় সেটা ব্যবহার করে Source 1সোর্স 1। একে বলে compaction। সারসংক্ষেপে আপনার রিকোয়েস্ট আর গুরুত্বপূর্ণ কোড থাকে। চ্যাটের শুরুর দিকের বিস্তারিত নির্দেশ হারিয়ে যেতে পারে Source 1সোর্স 1।

তাই জরুরি নিয়মগুলো শুধু চ্যাটে না রেখে CLAUDE.md-তে রাখুন Source 1সোর্স 1। কী রাখতে হবে তা Claude-কে বলেও দিতে পারেন: একটা ফোকাস দিয়ে /compact চালান, যেমন /compact focus on the API changes। উইন্ডো কী দিয়ে ভরেছে দেখতে /context চালান Source 1সোর্স 1।

Compaction in the API

If you build your own harness on the Claude API, the API docs name server-side compaction as the primary strategy for context management in long conversations and agentic workflows Source 2সোর্স 2. Compaction replaces the older turns of a conversation with a summary that Claude writes on the server, so you need no summarization code of your own Source 3সোর্স 3. There are two kinds: compaction on demand, where your application requests the summary, and compaction at a token threshold, where the API compacts when input tokens reach the trigger that you set. The docs advise on-demand compaction wherever it is available Source 3সোর্স 3.

The feature is in beta for Claude 4.6 and later models and Claude Mythos Preview Source 2সোর্স 2. The API docs also list tool result clearing: it clears old tool results in agentic workflows Source 2সোর্স 2.

সহজ English

If you build your own agent on the Claude API, the API can do the compaction for you on the server Source 2সোর্স 2. It replaces the old turns with a summary that Claude writes, so you do not write summary code yourself Source 3সোর্স 3. You can ask for the summary yourself (on demand), or you can set a limit, and the API compacts when the input reaches it. The docs advise on-demand compaction where it is available Source 3সোর্স 3.

This feature is in beta for Claude 4.6 and later models and Claude Mythos Preview Source 2সোর্স 2. The API can also clear old tool results to save space Source 2সোর্স 2.

বাংলা ব্যাখ্যা

Claude API দিয়ে নিজের এজেন্ট বানালে API সার্ভারেই আপনার জন্য compaction করতে পারে Source 2সোর্স 2। এটা পুরোনো টার্নগুলোর জায়গায় Claude-এর লেখা একটা সারসংক্ষেপ বসায়, তাই আপনাকে নিজে সারসংক্ষেপের কোড লিখতে হয় না Source 3সোর্স 3। দুই ধরন আছে: on-demand compaction, যেখানে আপনার অ্যাপ সারসংক্ষেপ চায়, আর token threshold compaction, যেখানে আপনার ঠিক করা trigger-এ ইনপুট পৌঁছালে API compaction করে। ডকুমেন্টেশন বলে, যেখানে পাওয়া যায় সেখানে on-demand compaction ব্যবহার করুন Source 3সোর্স 3।

এই ফিচারটা Claude 4.6 ও পরের মডেল এবং Claude Mythos Preview-এর জন্য beta-তে আছে Source 2সোর্স 2। জায়গা বাঁচাতে API পুরোনো tool result মুছেও দিতে পারে Source 2সোর্স 2।

What a tester can check

Tutorial advice

Most context bugs show only in long sessions. Test these:

  • Lost rule: give a rule early in a long session, force a compaction, then check that the agent still follows the rule.
  • Rule in CLAUDE.md: do the same with the rule in CLAUDE.md. Compare the two results.
  • Large tool output: a tool that returns a very large result. Check that the agent still answers well.
  • Old data: after compaction, check that the agent does not use an old value that a later step changed.

সহজ English

Tutorial advice

Context bugs often show only in long sessions. Try these:

  • Give a rule at the start, make the session long, and check that the agent still follows the rule.
  • Do the same with the rule in CLAUDE.md, and compare.
  • Make a tool return a very large result, and check the answer.
  • After a summary, check that the agent does not use an old value.

বাংলা ব্যাখ্যা

Tutorial advice

কনটেক্সটের বাগ সাধারণত লম্বা সেশনেই দেখা যায়। এগুলো চেষ্টা করুন:

  • শুরুতে একটা নিয়ম দিন, সেশন লম্বা করুন, তারপর দেখুন এজেন্ট এখনো নিয়মটা মানছে কি না।
  • একই কাজ নিয়মটা CLAUDE.md-তে রেখে করুন, তারপর তুলনা করুন।
  • একটা টুল দিয়ে খুব বড় একটা ফলাফল ফেরত দিন, তারপর উত্তরটা চেক করুন।
  • সারসংক্ষেপের পরে দেখুন এজেন্ট কোনো পুরোনো মান ব্যবহার করছে কি না।

Key words

TermMeaning
Context windowAll the text that the model sees in one request, its "working memory"
TokenThe unit in which the size of the context is counted
Context rotAccuracy and recall degrade as the token count grows
CompactionThe harness replaces older messages with a summary
/compactThe Claude Code command that compacts now, with an optional focus
/contextThe Claude Code command that shows what uses the space
CLAUDE.mdThe file of persistent rules of a Claude Code project

Reels on this topicএই টপিকের রিলস

Short videos from other creators, picked for this topic. They are not part of this page's fact-checked text. Nothing loads from YouTube until you press Play.অন্য ক্রিয়েটরদের বানানো ছোট ভিডিও, এই টপিকের জন্য বাছাই করা। এগুলো এই পেজের ফ্যাক্ট-চেক করা লেখার অংশ নয়। চালান বাটন চাপার আগে YouTube থেকে কিছুই লোড হয় না।

  1. [1]
    How Claude Code works

    Claude Code documentation · accessed 2026-10-28দেখা হয়েছে: 2026-10-28

  2. [2]
    Context windows

    Claude API documentation · accessed 2026-10-28দেখা হয়েছে: 2026-10-28

  3. [3]
    Compaction overview

    Claude API documentation · accessed 2026-10-28দেখা হয়েছে: 2026-10-28

  4. [4]
    Using the Messages API

    Claude API documentation · accessed 2026-10-28দেখা হয়েছে: 2026-10-28