← Back to Blog Data & Explainers

How Many Tokens Do AI Coding Agents Use?

Published July 2026

Quick answer

A single non-trivial coding task run through an AI agent commonly uses 50,000 to 500,000+ tokens, and long autonomous sessions can exceed 1 million. Usage is dominated by context, not your prompt: agents re-send the system prompt, tool definitions, files read, and prior turns on every step, so cost grows super-linearly with turns.

If your AI coding bill feels higher than your typing suggests it should be, you are not imagining it. Modern agents spend most of their tokens re-reading context, not reading your prompt. This explainer breaks down where those tokens actually go, with honest 2026 ranges you can sanity-check against your own usage.

Table of Contents

  1. Tokens Per Task: The Real Numbers
  2. Why Usage Grows Super-Linearly
  3. Where the Tokens Come From
  4. Terminal Agents vs. IDE Agents
  5. The Takeaway: Context Dominates

Tokens Per Task: The Real Numbers

Let us start with the number everyone wants. Based on observed usage across popular agents in 2026, a single non-trivial coding task — say, "add a feature and update the tests" — commonly lands somewhere between 50,000 and 500,000+ tokens. Trivial one-line edits can come in under 20,000. Long, autonomous sessions where the agent explores a large repo, reads dozens of files, runs commands, and iterates over many turns routinely push past 1 million tokens.

These are ranges, not precise measurements. Your actual numbers depend heavily on repo size, how aggressively the tool includes context, how many turns the task takes, and your configuration. Treat the figures below as observations to calibrate against, not laboratory constants.

Task TypeTypical Total TokensTurns
Trivial edit (one file, one change)10K – 40K1–3
Standard feature or bug fix50K – 250K4–15
Multi-file refactor200K – 600K10–30
Long autonomous session600K – 1M+30+

The spread is wide because these totals are cumulative across every turn. And that cumulative behavior is the single most important thing to understand about agent token usage. For a full picture of what those tokens translate to in dollars, see our breakdown of AI coding agent costs.

Why Usage Grows Super-Linearly

Here is the mechanism that surprises most people. LLMs are stateless. The model does not "remember" your previous turn — the agent has to re-send the entire relevant history on every single request. So each turn includes the system prompt, the tool definitions, every file already read into context, every command's output, and the full transcript of prior messages and diffs.

The consequence: a file the agent reads on turn 3 is re-transmitted on turns 4, 5, 6, and every turn after. Over a 30-turn session, that one file might be sent 27 times. This is why total token usage grows super-linearly with the number of turns rather than linearly with your prompt length. Doubling the length of a session more than doubles the tokens.

The compounding effect (illustrative)

Turn 1 context~8K tokens
Turn 5 context (history + 3 files read)~35K tokens
Turn 15 context (more history + 8 files)~90K tokens
Cumulative input across 15 turns~600K tokens

Notice that the biggest single line item is not any one turn — it is the accumulation. This is exactly why techniques like prompt caching, context pruning, and summarization matter so much for agents specifically, and why the same task can cost wildly different amounts depending on how the tool manages that growing payload.

Where the Tokens Come From

Break a single agent request into its parts and a consistent pattern emerges. There are four broad sources of tokens, and only one of them is the prompt you actually typed.

Token SourceTypical RangeNotes
System prompt + tool definitions5K – 20KFixed overhead, sent every turn
Repo map / project index (Aider-style)5K – 50KAdded upfront in some tools
Files read into context2K – 15K per fileLargest variable component
Command & tool outputs1K – 20K eachTest logs, grep, build output
Conversation history (re-sent)Grows every turnCompounds across the session
Your typed prompt50 – 800Usually the smallest share

A few things stand out. The system prompt and tool definitions are a fixed tax — often 5K to 20K tokens — paid on every turn before you do anything. Tools that ship large, detailed tool schemas pay this tax repeatedly. Repo-map features, like Aider's project map, add another 5K to 50K upfront so the model has a bird's-eye view of the codebase.

But the two components that usually dominate are files read into context and conversation history re-sent each step. A single moderately sized source file can be 2,000 to 15,000 tokens, and agents often read several. Once read, they linger in history and get re-sent. Command outputs — a verbose test run, a large grep result, a stack trace — pile on top. Want to estimate your own footprint before a session? Our token calculator converts text and files into token counts, and the AI coding tools pricing guide maps those tokens to each provider's rates.

Terminal Agents vs. IDE Agents

People often ask whether terminal agents like Claude Code, Aider, and Codex use more or fewer tokens than IDE agents like Cursor and GitHub Copilot. The honest answer is: it depends on the task and the configuration, and the tools differ mainly in how much context they auto-include.

Terminal agents tend to be explicit and autonomous — they read whole files, run commands, and keep long transcripts, which can drive high per-task totals on complex work. IDE agents often lean on editor context (open files, cursor position, symbol indexes) and may include less full-file content per turn for quick completions, but heavier agent modes narrow that gap. Some public comparisons have observed one agent using roughly 5x more tokens than another on the same task, driven largely by differences in repo-mapping, file-inclusion, and history-management defaults.

The practical lesson is not "tool A is cheaper than tool B" — it is that defaults matter enormously. The same underlying model can cost 5x more depending on how much the surrounding agent decides to stuff into context on your behalf. Configuration, not the model, is often the biggest lever you control.

The Takeaway: Context Dominates

If you remember one thing: token usage in coding agents is dominated by context, not by your prompt. The system prompt, tool definitions, files, outputs, and re-sent history together account for the overwhelming majority of tokens on any non-trivial task. Compressing the sentence you type saves a little; managing the context window saves a lot.

That said, verbose prompts and redundant file reads absolutely still add up over a long session — because everything you add gets carried forward and re-sent on every subsequent turn. A single unnecessary large file read on turn 4 quietly costs you tokens on turns 5 through 30. Small, repeated inefficiencies compound in exactly the same super-linear way that legitimate context does.

This is where visibility helps. Terse tracks per-turn token usage across your agent sessions and flags redundant reads and duplicate tool calls — so when the same file gets read three times or a grep repeats, you can see it instead of paying for it silently. It is a light touch: the goal is awareness, not micromanagement. Once you can watch the context grow turn by turn, you naturally keep sessions leaner. To turn those savings into a dollar figure, pair it with our guide to reducing AI API costs.

See Where Your Agent Tokens Go

Terse monitors Claude Code, Cursor, Aider, and Codex sessions in real time — tracking per-turn tokens, flagging duplicate tool calls and redundant reads, and compressing prompts on-device. Zero API calls, zero latency.

Download Terse

Frequently Asked Questions

How many tokens does a single coding task use?

Commonly 50,000 to 500,000+ tokens for a non-trivial task, and over 1 million for long autonomous sessions. Trivial edits can stay under 20,000. The variance comes from repo size, files read, and turn count.

Why do AI coding agents use so many tokens?

Because LLMs are stateless, agents re-send the full relevant context — system prompt, tools, files, outputs, and prior messages — on every turn. Usage therefore grows super-linearly with the number of turns.

Does my prompt length actually matter?

Your typed prompt is usually the smallest share of total tokens. But verbose prompts and redundant file reads still compound across a session, since everything you add is re-sent on every following turn.

Further Reading

Related articles

What Are GitHub Copilot AI Credits? Why Is Cursor So Expensive? Why Is Claude Code So Expensive?