Models get worse at using a long prompt well before the prompt runs out of room, a problem called context rot. A new test on five models with 1M-token windows shows where it hits AI agents: tallying events scattered across a long session, while looking up a single fact held up fine.
How the test worked
Researchers built synthetic coding-agent sessions packed with a few hundred tool calls, with TypeScript file reads, grep output, environment files and test logs filling the history. They planted four facts in each session:
- A ticket ID given by the user, next to a similar decoy ID
- The latest value of a worker setting that changed several times, with a distractor value from another service
- An early rule telling the agent not to touch a billing folder
- The number of test runs that failed, which was three
Five models ran the same sessions: Claude Haiku 5.5, GPT-6 Luna, Gemini 3.8 Flash, DeepSeek V4.1 Flash and MiniMax M3.1 Flash. Sessions ran at five sizes, from 64K up to 3.2M characters, with three seeds each. With so few runs, read the results as a trend rather than exact rates. Token counts also depend on the tokenizer: identical text came to roughly 50% more tokens on Claude Haiku 5.5 than on GPT-6 Luna.

Where context rot shows up
Every single-fact question was answered correctly at every length. Recalling the ticket, reporting the newest setting and obeying the early rule all scored 100% out to roughly 900K tokens.
Counting failed test runs behaved differently. The share of right answers sank from 67% near 20K tokens to 40% near 80K, then 27% near 600K. In long sessions the typical miss was answering 2, which means one failure went unnoticed. In short ones, the typical miss was 4.
A plain lookup test would have judged these models healthy. Real agents are often asked for something that spans the whole history, like a failure tally or a list of files already edited, and that is the kind of question that decayed. MiniMax M3.1 Flash stayed near the top at every size. The other four slipped as sessions got longer.

Why dropping old messages backfires
Cutting the oldest turns is the quick way to shorten a prompt, but it also erases facts the agent logged early on. At 2M characters, keeping only the system prompt, first user message and the most recent history cut accuracy from 49 of 60 answers to 9 of 60. The ticket ID, the newest setting and every failed run were gone. In one run a model made up a ticket, SEC-8492, which never appeared in the session.
The fix: chunked compaction
Compaction swaps older turns for a summary while leaving recent turns untouched. The team left the system prompt and final 8 messages as they were, cut the rest into pieces of roughly 16,000 characters, summarized the pieces at the same time and put the combined summary right after the system prompt.
At 2M characters, compaction raised accuracy from 49 of 60 to 54 of 60. It kept the ticket ID, the setting value and the billing rule every time. The failed-run count improved from 4 of 15 to 9 of 15.
The savings were large too. Prompts shrank on average from 605K tokens to 112K, and a typical request went from $0.224 to $0.041. Compacting a session cost about $0.023 and finished in 88 to 124 seconds.
What agent builders should do
Start early. Counting accuracy had already dropped to 40% at around 80K tokens, nowhere near any model’s limit, so set a token threshold that triggers compaction rather than waiting for an overflow error. Put standing rules and live settings in the system prompt or a running state note. Track counts and lists of edited files in state, since compaction raised the count score but didn’t make it perfect.
Sessions that overflow the window simply fail: at 3.2M characters, Claude Haiku 5.5 returned a 400 error for a prompt of about 1.29M tokens against its 1M cap.
Long prompts also cost money each step, because an agent resends its history every turn. At 2M characters a single request on Claude Haiku 5.5 or Gemini 3.8 Flash ran $0.40 to $0.45. Since context rot and the bill both grow with length, shorter histories help on both counts.
Source: OpenRouter Blog