Scott Wueschinski
← All AI and Agentic POV

The context window is a budget, and most agents overspend it

A 1M-token window is a credit limit, not a target. Treat context as a budget with tiers, eviction, and summaries that preserve the evidence.

AI & Agentic POV Production LLM Deployment

· 4 min read · Source: TinyFish Blog ↗

Your agent did not crash. It ran for 20 minutes, read nine pages, and quietly misreported a price on turn 5 that it had read correctly on turn three.

That is the failure mode nobody puts in the demo. The window never filled. No stack trace. The answer just got worse as the tokens stacked up. And it is the most expensive bug in production agents right now, because it hides.

Capacity is the wrong metric

Teams keep buying their way out with bigger windows. It is the reflex, and it fails on contact with real traffic. Context rot is not context window overflow. Overflow happens when you exceed the model’s maximum token limit. Rot happens well before that. A model with a 200K token window can exhibit significant degradation at 50K tokens.

Chroma proved this across the frontier. A larger window just gives you more room to fill with irrelevant tokens. The spec sheet number is a credit limit. The documented context window is what you’re allowed to send. Your usable window is where the model still hits your quality bar. Those are different numbers, and the second is usually a fraction of the first.

Anthropic put the right frame on it months ago. Context must be treated as a finite resource with diminishing marginal returns. Like humans, who have limited working memory capacity, LLMs have an attention budget that they draw on when parsing large volumes of context.

Read that word again: budget. Every token you spend earns interest in latency, dollars, and lost accuracy. Most agents run a deficit on turn one.

Where the overspend happens

The biggest line item is almost always the retrieval layer, where a single fetch can dwarf an entire conversation. The unit of rot is the retrieval, not the turn: one fetch returning 3% article content does more damage on turn one than 40 clean turns. Cleaning input at the retrieval layer is the highest-leverage fix.

TinyFish ran the numbers on a single news article. One fetch returned 4,673 characters at around 92% article content. A competing service returned 164,986 characters at around 3%, padded with site navigation, a weather widget, trending links and ad slots. At roughly four characters per token, that’s about 1,170 input tokens versus about 41,000 for the same article. Thirty-five times the cost, for the same information.

The bill is the smaller problem. Those junk tokens aren’t inert filler. Trending headlines and related-article rails sitting beside a news story are textbook distractors: same topic, same vocabulary, no answer to your question. That’s the exact condition Chroma showed degrades accuracy, delivered in one API call.

The other overspend is the dumping habit. Early agent implementations fall into the context dumping trap: placing a 5MB CSV, a massive JSON API response, or a full PDF transcript directly into the chat history. This creates a permanent tax on the session; every subsequent turn drags that payload along, burying critical instructions and inflating costs.

Run it like a budget: tiers, eviction, evidence

Give the window a spending plan before the agent writes a single token.

Tier it. Stable prefixes (system identity, policies) stay byte-stable so prefix caching keeps the bill down. A task-scoped working set carries the current goal. Tool output is disposable by default. Large payloads live outside the prompt entirely: large data lives in the artifact store, not the prompt, and you pass a handle. AWS reported the payoff when this discipline is applied end to end: a single write-and-execute tool cut the tokens each script adds to context by about 95 percent, and loading skills on demand shrank the system prompt by about 97 percent.

Evict on a policy, not on panic. What gets retrieved, in what order, and what gets evicted when the window fills is systems work: caching policy, eviction policy, and a relevance ranker in new clothes. Decide what ages out and when, before the window hits 95 percent and the model auto-compacts behind your back.

Summarize to preserve evidence. Compaction is where most teams lose the thread. Compaction summarizes a conversation approaching the window limit and reinitializes a new window with the summary. It reduces context size but can lose detail: omitted information is unavailable unless retained in logs, files, or another retrievable store. The fix is a compaction prompt that names what must survive: the task statement, decisions made, file paths already inspected and what each contained, open questions. A summary built to carry evidence forward is reusable. A vibe-summary is a liability.

The Cost of Doing Nothing

CODN on context is invisible until it is catastrophic. It stays off every dashboard. It surfaces in the customer who got the wrong number, the eval that passed in week one and drifted by week ten, and the six-figure window upgrade that bought you nothing because capacity was never the constraint.

The teams who win the next 18 months will treat the window like a P&L. They meter every token in, price distractors as a cost, and spend attention where it compounds. Give your agent a budget, enforce it in code, and the accuracy follows the money.