Learn · How agents work
Why do AI agents forget mid-task?
A large context window is not a filing cabinet. As an agent runs step after step, raw tool logs pile up in the window and crowd out the rules you gave it at the start. Compress old logs into a working note and watch what returns.
Free lesson, about five minutes. Updated
- Rule still followed
- Rule forgotten in the noise
- Rules followed
- 5 of 6from step 1
- Signal share
- 13%of the window
- Window size
- 21,750tokens sent
- Raw log noise
- 19,000tokens of old dumps
-
1 PredictWhat happens by step 25 of a long task?
You give an agent 6 standing rules at the start of a job, then let it run 25 steps of searching files and reading tool outputs. Every raw tool output stays in the conversation history, totaling 102,750 tokens well inside a 200,000-token context window. How well does it follow the 6 rules on step 25?
Pick one first. A guess that turns out wrong teaches the most.
Locked in. Now test it.
-
2 TryRun 25 steps, then prune the old tool dumps
First move Steps into the task from 5 to 25 and watch the rules drop. Then move Old tool logs compressed to 80%.
- Rules followed
- 5 of 6
- Signal share
- 13%
-
3 ObserveWere you right?
Commit to a prediction first.
-
4 ExplainWhy does it come out this way?
Fitting inside a context limit is not the same as paying attention to all of it. Every token in the window competes for the model’s attention. When 90,000 tokens of old search results, HTML fragments and dead-end tool outputs sit between your initial instructions and the current step, the rules from step 1 get drowned out.
Good harnesses treat the context window like a clean workbench: after each step, the harness writes the verified facts into a short structured note and archives the raw tool dump outside the prompt.
-
5 ApplyA new case
An agent that reconciles monthly vendor statements works well on statements with 10 lines and starts making up invoice numbers halfway through statements with 150 lines. What is the cleanest fix?
A bigger window only lets you pile up more raw noise before it breaks. Attention still degrades when 150 tool calls sit in one transcript.
Right. Code holds the 150 rows in a table and hands the model one small batch at a time in a clean context window, so step 150 has the exact same signal-to-noise ratio as step 1.
Repeating the prompt adds tokens without clearing the 150 old tool outputs that are confusing the model.
The math behind the figure
- Signal tokens start at 1,500 tokens for the task instructions and standing rules, plus 250 tokens of verified facts discovered at each step.
- Raw tool noise adds 3,800 tokens per step from unpruned search results, file reads and tool responses.
- Compressing old logs replaces completed tool outputs with their short extracted result, cutting raw noise by the percentage chosen.
- Standing rules followed tracks the share of signal in the active window: above 28% signal all 6 rules hold, while below 8% signal only 2 of 6 hold reliably.
How agents work
Three lessons on what sits around a model, why agents lose track of long tasks, and how AI search engines score your pages.
- 1What is an agent harness?5 minutes
- 2Why do AI agents forget mid-task?This lesson
- 3Why do clear headings get your site cited by AI?5 minutes