Working Memory
Working memory is what an agent has "in mind" right now: the task, the last messages, and the tool results of the current step. It has a limited size, and a new session starts without it. This is topic 1 of 7. The 7 names follow the infographic "7 Types of Agent Memory". Research papers group memory in other ways.
8 min read8 মিনিটে পড়া যায় · 7 sections7টি সেকশন · 4 sources4টি সোর্স · updated Nov 2026আপডেট: Nov 2026
The context window fills upcontext window ভরে যায়
Watch each step add to the window until an early rule is far away. Then switch to many tools.প্রতিটা ধাপ কীভাবে window ভরে, দেখুন, যতক্ষণ না শুরুর নিয়মটা অনেক দূরে চলে যায়। তারপর অনেক টুলে বদলান।
You’ll learnআপনি শিখবেন
- What takes space in the context windowcontext window-এ কী কী জায়গা নেয়✓
- Why working memory grows each stepপ্রতি ধাপে working memory কেন বড় হয়
- Why an early rule can drift awayশুরুর নিয়ম কেন দূরে সরে যেতে পারে
- Why many tools leave less roomঅনেক টুল কেন জায়গা কমায়
- Why a new session starts emptyনতুন session কেন খালি শুরু হয়
In plain words
Working memory holds the information that the agent uses for the current step Source 1সোর্স 1. It is short-term Source 1সোর্স 1. Tutorial's own view: the agent does not keep it for the next session, unless an app stores it elsewhere.
For a large language model (LLM), Anthropic calls the context window the model's "working memory" Source 3সোর্স 3. The context window is different from the training data of the model Source 3সোর্স 3. The system prompt, the messages, the tool results, and the tool definitions all use space in it Source 3সোর্স 3.
The 7 names of this module follow the infographic. Research papers group memory differently. For example, the CoALA paper has working memory and three types of long-term memory: episodic, semantic, and procedural Source 1সোর্স 1. The other topics of this module, such as semantic memory and episodic memory, describe the long-term side.
সহজ English
Working memory is what the agent uses for the step it is doing now Source 1সোর্স 1. It is short-term Source 1সোর্স 1. Tutorial's own view: the agent does not keep it for the next session, unless an app stores it elsewhere.
For a large language model (LLM), Anthropic calls the context window the model's "working memory" Source 3সোর্স 3. This is not the data that the model learned in training Source 3সোর্স 3. The system prompt, the messages, the tool results, and the tool definitions all take space in it Source 3সোর্স 3.
The 7 names of this module come from the infographic. Research papers sort memory in other ways. The CoALA paper, for example, has working memory and three long-term types: episodic, semantic, and procedural Source 1সোর্স 1. The other topics of this module, such as semantic memory and episodic memory, explain the long-term side.
বাংলা ব্যাখ্যা
Working memory হলো সেই তথ্য, যা agent এখনকার step-এর জন্য ব্যবহার করে Source 1সোর্স 1। এটা short-term Source 1সোর্স 1। Tutorial-এর নিজের মত: পরের session-এর জন্য agent এটা রাখে না, যদি না কোনো app এটা অন্য কোথাও রাখে।
একটা large language model (LLM)-এর ক্ষেত্রে Anthropic context window-কে model-এর "working memory" বলে Source 3সোর্স 3। এটা model-এর training data থেকে আলাদা Source 3সোর্স 3। system prompt, message, tool result আর tool definition, সবই এর জায়গা নেয় Source 3সোর্স 3।
এই module-এর 7টা নাম infographic থেকে নেওয়া। research paper-গুলো memory-কে অন্যভাবে ভাগ করে। যেমন CoALA paper-এ আছে working memory আর তিন ধরনের long-term memory: episodic, semantic আর procedural Source 1সোর্স 1। এই module-এর অন্য topic, যেমন semantic memory আর episodic memory, long-term দিকটা ব্যাখ্যা করে।
Where it comes from
In psychology. The term comes from the study of human memory. Working memory keeps information for a short time, in a state that is easy to use Source 2সোর্স 2. The common model is from Baddeley and Hitch (1974). In that model, working memory stores and changes information for tasks such as learning, reasoning, and comprehension Source 2সোর্স 2. Its central executive has a limited capacity Source 2সোর্স 2.
In AI agents. The CoALA paper uses the same name for a module of a language agent. Working memory keeps the active information for the current decision cycle Source 1সোর্স 1. It holds the inputs, knowledge from reasoning or from long-term memory, and data from the previous cycle Source 1সোর্স 1. CoALA calls it the central hub that connects the other parts of the agent Source 1সোর্স 1. The idea is older than LLMs. In the Soar architecture, working memory holds the recent input, the goals, and the results of internal reasoning Source 1সোর্স 1.
Two views. CoALA defines working memory as a module of the agent. It does not say that it is the context window. The Anthropic docs give the second view: the context window is the model's working memory Source 3সোর্স 3. Tutorial's own view: in a simple chat agent, the two views are close, because the agent puts its active information into the prompt.
সহজ English
In psychology. The name comes from research on human memory. Working memory keeps information for a short time, ready to use Source 2সোর্স 2. The best-known model is from Baddeley and Hitch (1974). In it, working memory holds and changes information for tasks such as learning, reasoning, and understanding Source 2সোর্স 2. The part that controls it can handle only a limited amount Source 2সোর্স 2.
In AI agents. The CoALA paper uses the same name for one part of a language agent. It keeps the active information for the current decision cycle Source 1সোর্স 1. That is the inputs, knowledge from reasoning or from long-term memory, and data from the last cycle Source 1সোর্স 1. CoALA calls it the central hub that links the other parts Source 1সোর্স 1. The idea is older than LLMs. In the Soar architecture, working memory holds the recent input, the goals, and the results of the agent's own reasoning Source 1সোর্স 1.
Two views. For CoALA, working memory is a part of the agent, not the context window. The Anthropic docs give the other view: the context window is the model's working memory Source 3সোর্স 3. Tutorial's own view: in a simple chat agent, the two are close, because the agent puts its active information into the prompt.
বাংলা ব্যাখ্যা
Psychology-তে। নামটা এসেছে মানুষের memory নিয়ে গবেষণা থেকে। Working memory অল্প সময়ের জন্য তথ্য রাখে, এমনভাবে যে তা সহজে ব্যবহার করা যায় Source 2সোর্স 2। সবচেয়ে প্রচলিত model-টা Baddeley আর Hitch-এর (1974)। এই model-এ working memory learning, reasoning আর comprehension-এর মতো কাজের জন্য তথ্য রাখে আর বদলায় Source 2সোর্স 2। এর central executive-এর capacity সীমিত Source 2সোর্স 2।
AI agent-এ। CoALA paper একই নাম language agent-এর একটা module-এর জন্য ব্যবহার করে। এটা এখনকার decision cycle-এর active তথ্য রাখে Source 1সোর্স 1। এর মধ্যে আছে input, reasoning বা long-term memory থেকে পাওয়া knowledge, আর আগের cycle-এর data Source 1সোর্স 1। CoALA এটাকে central hub বলে, যা agent-এর অন্য অংশগুলো জোড়ে Source 1সোর্স 1। ধারণাটা LLM-এর চেয়ে পুরোনো। Soar architecture-এ working memory রাখে সাম্প্রতিক input, goal আর internal reasoning-এর ফলাফল Source 1সোর্স 1।
দুটো দৃষ্টিভঙ্গি। CoALA working memory-কে agent-এর একটা module হিসেবে define করে। এটা context window-এর সমান বলে না। Anthropic docs দ্বিতীয় দৃষ্টিভঙ্গি দেয়: context window হলো model-এর working memory Source 3সোর্স 3। Tutorial-এর নিজের মত: সাধারণ chat agent-এ দুটো প্রায় একই, কারণ agent তার active তথ্য prompt-এ রাখে।
How an agent gets it
An LLM agent fills its working memory each time that it sends a request to the model. All parts of the request use space in the context window: the system prompt, each message, the tool results, images, documents, and the tool definitions Source 3সোর্স 3.
one request = the working memory of one step
+--------------------------------------------+
| system prompt |
| tool definitions |
| message 1 (user) |
| message 2 (assistant, tool call) |
| message 3 (tool result) |
| ... |
| message N (the newest user message) |
+--------------------------------------------+
|
v
model response -> usage (tokens used)The agent adds the new answer and the next tool result, then sends a new request. So the working memory grows with each step Source 3সোর্স 3. The space is limited. When input plus max_tokens is more than the window, Claude 4.5 models and newer accept the request and stop with stop_reason: "model_context_window_exceeded" if generation reaches the limit; earlier models return a validation error Source 3সোর্স 3. If the input alone is too long, every model returns a 400 "prompt is too long" error Source 3সোর্স 3.
Two facts help you to measure it. Each response reports the tokens of the request in its usage field Source 3সোর্স 3. You can also estimate a request before you send it with the token counting API Source 3সোর্স 3.
Tutorial's own view: what is not in the request, the model cannot use in that step. Facts from earlier sessions must come back in through a long-term store, for example retrieval memory.
সহজ English
An LLM agent fills its working memory each time it sends a request to the model. Everything in the request takes space in the context window: the system prompt, every message, the tool results, images, documents, and the tool definitions Source 3সোর্স 3.
one request = the working memory of one step
+--------------------------------------------+
| system prompt |
| tool definitions |
| message 1 (user) |
| message 2 (assistant, tool call) |
| message 3 (tool result) |
| ... |
| message N (the newest user message) |
+--------------------------------------------+
|
v
model response -> usage (tokens used)The agent adds the new answer and the next tool result, and sends a new request. So working memory grows with each step Source 3সোর্স 3. The space has a limit. When input plus max_tokens is more than the window, Claude 4.5 models and newer accept the request and stop with stop_reason: "model_context_window_exceeded" if generation reaches the limit; older models give a validation error Source 3সোর্স 3. If the input alone is too long, every model returns a 400 "prompt is too long" error Source 3সোর্স 3.
You can measure it. Each response tells you how many tokens the request used, in the usage field Source 3সোর্স 3. You can also estimate a request before you send it, with the token counting API Source 3সোর্স 3.
Tutorial's own view: if something is not in the request, the model cannot use it in that step. Facts from older sessions must come back from a long-term store, for example retrieval memory.
বাংলা ব্যাখ্যা
LLM agent প্রতিবার model-এ request পাঠানোর সময় তার working memory ভরে। request-এর সবকিছু context window-এর জায়গা নেয়: system prompt, প্রতিটা message, tool result, image, document আর tool definition Source 3সোর্স 3।
one request = the working memory of one step
+--------------------------------------------+
| system prompt |
| tool definitions |
| message 1 (user) |
| message 2 (assistant, tool call) |
| message 3 (tool result) |
| ... |
| message N (the newest user message) |
+--------------------------------------------+
|
v
model response -> usage (tokens used)agent নতুন উত্তর আর পরের tool result যোগ করে, তারপর নতুন request পাঠায়। তাই প্রতি step-এ working memory বড় হয় Source 3সোর্স 3। জায়গা সীমিত। input আর max_tokens মিলে window-এর বেশি হলে Claude 4.5 আর নতুন model request নেয় এবং generation limit-এ পৌঁছালে stop_reason: "model_context_window_exceeded" দিয়ে থামে; পুরোনো model validation error দেয় Source 3সোর্স 3। শুধু input-ই বেশি লম্বা হলে সব model 400 "prompt is too long" error দেয় Source 3সোর্স 3।
আপনি এটা মাপতে পারেন। প্রতিটা response তার usage field-এ request-এর token জানায় Source 3সোর্স 3। পাঠানোর আগে token counting API দিয়েও request-এর আকার আন্দাজ করা যায় Source 3সোর্স 3।
Tutorial-এর নিজের মত: যা request-এ নেই, model সেই step-এ তা ব্যবহার করতে পারে না। আগের session-এর তথ্য long-term store থেকে ফিরিয়ে আনতে হয়, যেমন retrieval memory।
A real-life example
This example is the tutorial's own illustration. It shows no measured result.
A tester asks a coding assistant, such as Claude Code, to fix a flaky login test. The working memory of the first step has the system prompt, the tool definitions, and the request. The assistant reads the test file and the log of the failed run. Both tool results go into the next request.
The tester adds a rule early in the session: "Do not change the test data file." Then the session runs for a long time. The assistant reads many files and long logs. The rule is now far from the end of the context.
The rule is still in the context window. But more context is not always better: accuracy and recall go down as the token count grows Source 3সোর্স 3. This is known as "context rot" Source 3সোর্স 3. So the tester checks the final diff for the test data file, and does not trust that the assistant remembered the rule.
The next day, the tester opens a new session. The rule is not in the new context. Tutorial's own view: a rule that must last belongs in a long-term store, for example a project file that the tool loads at the start (see procedural memory).
সহজ English
This example is the tutorial's own. It shows no measured result.
A tester asks a coding assistant, such as Claude Code, to fix a flaky login test. In the first step, working memory has the system prompt, the tool definitions, and the request. The assistant reads the test file and the log of the failed run. Both results go into the next request.
Early in the session, the tester adds a rule: "Do not change the test data file." The session then runs for a long time. The assistant reads many files and long logs. The rule is now far from the end of the context.
The rule is still in the context window. But more context is not always better: accuracy and recall drop as the number of tokens grows Source 3সোর্স 3. This is known as "context rot" Source 3সোর্স 3. So the tester checks the final diff for the test data file. They do not just trust that the assistant remembered.
The next day, the tester starts a new session. The rule is not in the new context. Tutorial's own view: a rule that must last goes into a long-term store, for example a project file that the tool loads at the start (see procedural memory).
বাংলা ব্যাখ্যা
এই উদাহরণটা tutorial-এর নিজের। এতে কোনো মাপা ফলাফল নেই।
একজন টেস্টার Claude Code-এর মতো একটা coding assistant-কে একটা flaky login test ঠিক করতে বলেন। প্রথম step-এর working memory-তে থাকে system prompt, tool definition আর request। assistant test file আর failed run-এর log পড়ে। দুটো tool result-ই পরের request-এ যায়।
session-এর শুরুতে টেস্টার একটা নিয়ম দেন: "test data file বদলাবেন না।" তারপর session অনেকক্ষণ চলে। assistant অনেক file আর লম্বা log পড়ে। নিয়মটা এখন context-এর শেষ থেকে অনেক দূরে।
নিয়মটা এখনো context window-এ আছে। কিন্তু বেশি context সবসময় ভালো নয়: token বাড়লে accuracy আর recall কমে Source 3সোর্স 3। এটা "context rot" নামে পরিচিত Source 3সোর্স 3। তাই টেস্টার final diff-এ test data file দেখে নেন। assistant নিয়মটা মনে রেখেছে, এটা ধরে নেন না।
পরের দিন টেস্টার নতুন session খোলেন। নতুন context-এ নিয়মটা নেই। Tutorial-এর নিজের মত: যে নিয়ম টিকে থাকতে হবে, তা long-term store-এ রাখুন, যেমন এমন একটা project file যা tool শুরুতেই load করে (procedural memory দেখুন)।
Common mistakes
"A bigger context window solves everything." It does not. Accuracy and recall go down as the token count grows Source 3সোর্স 3. A long, noisy context can make the answer worse.
"The model reads every part of a long input equally well." A study found that models use information at the start or the end of a long input best. It found a large drop when the key information is in the middle Source 4সোর্স 4. That study tested the models of 2023, so test your own model.
"Working memory is the training data." It is not. The context window is different from the large set of data that the model was trained on Source 3সোর্স 3. A fact in the training data is a different type of memory: see parametric memory.
"Only the chat messages count." The system prompt, the tool results, images, documents, and the tool definitions also use space Source 3সোর্স 3. An agent with many tools has less space for the conversation.
"The app will never hit the limit." It can. Then Claude 4.5 models and newer stop with model_context_window_exceeded, and earlier models return a validation error; if the input alone is too long, every model returns a 400 error Source 3সোর্স 3. An app that does not handle this can show a cut answer or crash.
"CoALA says working memory is the context window." It does not. CoALA describes a module that holds variables for the current decision cycle Source 1সোর্স 1. The "context window as working memory" view is from the Anthropic docs Source 3সোর্স 3.
সহজ English
"A bigger context window fixes everything." No. Accuracy and recall drop as the number of tokens grows Source 3সোর্স 3. A long, messy context can make the answer worse.
"The model reads all of a long input equally well." A study found that models use information at the start or the end best. It found a big drop when the key information is in the middle Source 4সোর্স 4. That study tested the models of 2023, so test your own model.
"Working memory is what the model learned in training." No. The context window is different from the training data Source 3সোর্স 3. Knowledge from training is a different type: see parametric memory.
"Only the chat messages take space." The system prompt, tool results, images, documents, and tool definitions take space too Source 3সোর্স 3. An agent with many tools has less room for the conversation.
"The app will never reach the limit." It can. Then Claude 4.5 models and newer stop with model_context_window_exceeded, and older models give a validation error; if the input alone is too long, every model returns a 400 error Source 3সোর্স 3. An app that does not handle this can show a cut-off answer or crash.
"CoALA says working memory is the context window." No. CoALA describes a part of the agent that holds data for the current decision cycle Source 1সোর্স 1. The "context window as working memory" view comes from the Anthropic docs Source 3সোর্স 3.
বাংলা ব্যাখ্যা
"বড় context window সব সমস্যার সমাধান।" না। token বাড়লে accuracy আর recall কমে Source 3সোর্স 3। লম্বা, এলোমেলো context উত্তর খারাপ করতে পারে।
"লম্বা input-এর সব অংশ model সমানভাবে পড়ে।" একটা গবেষণায় দেখা গেছে, input-এর শুরু বা শেষের তথ্য model সবচেয়ে ভালো ব্যবহার করে। দরকারি তথ্য মাঝখানে থাকলে ফলাফল অনেক খারাপ হয় Source 4সোর্স 4। ওই গবেষণা 2023-এর model পরীক্ষা করেছিল, তাই আপনার নিজের model টেস্ট করুন।
"Working memory মানে training data।" না। context window, model যে বড় data-তে train হয়েছে, তা থেকে আলাদা Source 3সোর্স 3। training থেকে পাওয়া জ্ঞান আলাদা ধরনের memory: parametric memory দেখুন।
"শুধু chat message জায়গা নেয়।" system prompt, tool result, image, document আর tool definition-ও জায়গা নেয় Source 3সোর্স 3। অনেক tool থাকলে conversation-এর জন্য জায়গা কম থাকে।
"App কখনো limit-এ পৌঁছাবে না।" পৌঁছাতে পারে। তখন Claude 4.5 আর নতুন model model_context_window_exceeded দিয়ে থামে, আর পুরোনো model validation error দেয়; শুধু input-ই বেশি লম্বা হলে সব model 400 error দেয় Source 3সোর্স 3। App এটা handle না করলে কাটা উত্তর দেখাতে পারে বা crash করতে পারে।
"CoALA বলে working memory মানে context window।" না। CoALA এমন একটা module-এর কথা বলে, যা এখনকার decision cycle-এর variable রাখে Source 1সোর্স 1। "context window হলো working memory" দৃষ্টিভঙ্গিটা Anthropic docs-এর Source 3সোর্স 3।
What a tester can check
These test ideas come from the facts above. They are the tutorial's own advice.
Tutorial advice
- Give a rule early in a long conversation. Check that the agent still follows it after many turns and long tool results.
- Put one key fact in the middle of a long input. Check that the answer uses it. Then move the fact to the start and to the end, and compare.
- Compare the
usagenumbers of a response with the token counting API for the same request. - Fill the context on purpose. Check that the app handles
model_context_window_exceededwith a clear message, not a cut answer or a crash. - Start a new session. Check that the app does not claim to remember the old session, unless it has a long-term store.
সহজ English
These test ideas come from the facts above. They are the tutorial's own advice.
Tutorial advice
- Give a rule early in a long chat. Check that the agent still follows it after many turns and long tool results.
- Put one key fact in the middle of a long input. Check that the answer uses it. Then move the fact to the start and to the end, and compare.
- Compare the
usagenumbers of a response with the token counting API for the same request. - Fill the context on purpose. Check that the app shows a clear message for
model_context_window_exceeded, not a cut-off answer or a crash. - Start a new session. Check that the app does not claim to remember the old one, unless it has a long-term store.
বাংলা ব্যাখ্যা
এই test idea-গুলো উপরের তথ্য থেকে নেওয়া। এগুলো tutorial-এর নিজের পরামর্শ।
Tutorial advice
- লম্বা conversation-এর শুরুতে একটা নিয়ম দিন। অনেক turn আর লম্বা tool result-এর পরেও agent নিয়মটা মানে কি না দেখুন।
- লম্বা input-এর মাঝখানে একটা দরকারি তথ্য রাখুন। উত্তর তথ্যটা ব্যবহার করে কি না দেখুন। তারপর তথ্যটা শুরুতে আর শেষে সরিয়ে তুলনা করুন।
- একই request-এর জন্য response-এর
usageসংখ্যা token counting API-এর সাথে মিলিয়ে দেখুন। - ইচ্ছা করে context ভরে ফেলুন। App
model_context_window_exceededস্পষ্ট message দিয়ে handle করে কি না দেখুন, কাটা উত্তর বা crash নয়। - নতুন session শুরু করুন। long-term store না থাকলে app আগের session মনে রাখার দাবি করে না, তা দেখুন।
Key words
| Term | Meaning |
|---|---|
| Working memory | The information that an agent keeps active for the current step or decision cycle. |
| Context window | All the tokens that an LLM can use for one response: the request and the response itself. Anthropic calls it the model's "working memory". |
| Token | A small piece of text. The context window and the usage field count tokens. |
| Decision cycle | In CoALA, one step of the agent's loop. Working memory holds the active data of the current cycle. |
| Context rot | The drop in accuracy and recall as the token count of the context grows. |
| Lost in the middle | The finding that models use information at the middle of a long input worse than at its start or end. |
usage | The field of an API response that reports the tokens that the request used. |
model_context_window_exceeded | The stop reason of Claude 4.5 models and newer when the output reaches the context window limit. |