All posts
GuidesMarket

The Agent Context Tax: Why AI Agents Are Slow and Costly

Your AI agent isn't slow because the model is bad — it burns tokens re-reading files it already knows. What the context tax is and how to cut it.

Younes Alturkey
Younes Alturkey
September 2, 2026·3 days ago
The Agent Context Tax: Why AI Agents Are Slow and Costly

Your AI agent isn't slow or expensive because the model is bad — it's slow because it burns tokens reading things it already knows. This is the "context tax," and it's one of the biggest hidden costs of running any agent. SonarSource's recent measurements show agents pay large, repeated token costs when they rely on file greps and whole-file reads instead of targeted context — and fixing it cut token usage and cost by up to 36%.

That number applies to more than code. Any agent that does repeated lookups pays the same tax. Understanding it is the cheapest way to make your agent faster and cheaper.

What the context tax actually is

Here's the problem. When an agent needs to do a task, it has to understand the relevant context first. A naive agent does that by reading a lot — grepping for keywords, pulling in whole files, re-reading the same material on every turn. That's expensive on two axes:

  • Tokens. Every file it reads gets fed to the model, and you pay for those tokens whether they're useful or not.
  • Round-trips. Each read is a model call. More calls, with thin context, means more latency and more cost.

The tax is that the agent carries far more context than it actually needs. SonarSource's research found that agents pay large, repeated token costs precisely when they rely on blind file reads and whole-file reads, rather than answering targeted navigation queries.

That's why they were able to cut token consumption and cost per run by up to 36% just by changing how the agent gets context — not by changing the model.

Where the waste comes from

The waste isn't the model's fault; it's the agent's navigation strategy. Imagine asking a colleague a question and instead of answering, they read your entire filing cabinet every time. That's what a grep-based agent does. It reads everything, then guesses what's relevant.

This snowballs as the agent works. Each step can pull in more context than it needs, the context grows, the cost and latency grow, and the agent gets slower and more error-prone as it navigates by brute force. It's a compounding problem, and it's the reason agents keep failing on things that should be simple.

How to cut the tax

The fix is to give the agent the right context the first time, instead of a pile of files and hope. Four moves work:

  1. Give it a map, not the atlas. A semantic graph or dependency index answers "where is X" directly, instead of re-reading everything to find out. This is the single biggest win.
  2. Scope the task tightly. A narrow task needs less context than a vague "help me with this project." Be specific about what you want.
  3. Read the minimum. Query for the precise symbols, references, and call flows you need — not the whole file.
  4. Watch the round-trips. Fewer model calls with better context beats many calls with thin context. Cost and speed both improve.

That last point is important. The goal isn't to feed the model less data in total; it's to feed it the right data so it doesn't have to keep going back. Fewer, better-informed calls is the whole trick.

Why this matters for a personal agent

You don't need to be a developer to benefit. If your agent does repeated lookups — searching your notes, your calendar, your past conversations — the same tax applies. The fix is the same: make sure it has the context it needs up front, rather than searching every time.

That's a strong argument for giving an agent memory it can query and for the right tools and permissions, so it reaches for the right thing instead of reading everything. A well-scoped task with the right context is the difference between an agent that feels instant and one that feels like it's thinking for a minute.

This is also why cheaper models can now run agents — a lot of what made agents expensive was this waste, not the model itself. Cut the waste and the whole thing gets cheaper.

The takeaway

The context tax is real and measurable — up to 36% of an agent's token cost in SonarSource's tests came down just by changing how it navigates. The lesson transfers: give your agent the right context the first time, scope tasks tightly, and read the minimum. The cheapest, fastest agent you'll ever run is the one that gets context right on the first try, not the one that re-reads everything.

One-page takeaway: the agent context tax