{"slug": "understanding-the-cost-of-coding-agents", "title": "Understanding the cost of coding agents", "summary": "AI coding agents incur costs through tokens, with billing complexities including input, cached input, output, reasoning, and cache-write tokens. Uber burned through its 2026 AI budget in four months on Claude Code, and GitHub's Copilot shifted to metered AI billing, signaling industry trends. Understanding token flow and cache optimization is crucial for managing AI budgets.", "body_md": "From individual developers running out of tokens on a daily basis to [Uber famously burning through the yearly budget in just four months](https://www.forbes.com/sites/janakirammsv/2026/05/17/uber-burns-its-2026-ai-budget-in-four-months-on-claude-code/), AI cost in both tokens and dollars is at the center of attention. Even for those who are happy with their AI subscriptions, the API-equivalent cost matters. Once you max out subscription tokens, you can add credits and effectively move into metered usage. Also, [Copilot’s shift to metered AI billing](https://www.theregister.com/software/2026/04/28/microsofts-github-shifts-to-metered-ai-billing/5224151) raises the possibility that other providers will make the same switch.\n\nThis article is for those who want to understand how AI billing works in general and how it applies to coding agents. If you are a leader in charge of an AI budget, a TPM figuring out project constraints, or a founder thinking through cost models, this should be a helpful guide. It won’t explain the basic concepts like a “token” or “coding agent”, but it will discuss how tokens flow through the system and show up in your telemetry and billing, as well as how performance and engineering issues can affect your budget.\n\nOne of the challenges with understanding AI billing is that “token” is a very generic term. You don’t just spend “tokens.” You spend input, cached input, output, reasoning, and sometimes cache-write tokens. These are not interchangeable, because they have different prices and tell you different things about agent and model behavior.\n\nThe diagram above shows the overall agentic loop and what you pay for during its execution. Let’s look at each part.\n\nThe agent collects client-side data — from the user prompt to file contents and tool call results — and sends it to the LLM via the HTTP request. This step is usually free of charge.\n\nWhatever the agent sends to the LLM is called “context” and when you hear discussions about “context window” — this is what it refers to. Context window size is more of an engineering metric than a business metric. It defines how much data the agent can send, but there is no direct billing associated with it. If the provider increases the context window, it won’t necessarily affect your bill.\n\nThe AI provider processes the input, and this is where another common term appears: “prompt cache.” The name is a bit misleading, because it’s more of a general context cache. This is not technically part of the LLM, but most AI providers use it these days.\n\nThe implementation of caching and its billing can differ, but overall it works like this. The data sent from the client always contains the full content, but it still needs to be converted into tokens, or “tokenized”.\n\nBecause of the agentic loop, the system normally sends the same data over and over again and appends new data at the end. To avoid reprocessing the data multiple times, the providers cache it.\n\nLet’s say your agent read five files in the previous step and now added a sixth one. The agent sends all six files to the provider, but five of them will be read from a cache and only one will be considered “fresh input”.\n\nWhy is this important? Because cached input is typically 10x cheaper than new input. So you will pay the cache token price for five files and the input token price for just one file. The new file will be added to the cache, and during the next agentic cycle you will pay the cached token price for all six files.\n\nCache optimization is a topic of its own. Some providers, like Anthropic, charge separately for writing to it and let you control the amount of time the data lives in the cache. Others, like OpenAI, have fully automated the process and bundled the cost of cache writes into the cost of fresh input tokens.\n\nThere are two engineering terms you might have heard of: “cache hit” and “cache invalidation”. “Cache hit” means the system finds the old data in the cache and you pay less. “Cache invalidation” means that the data isn’t found, so you pay the input token price.\n\nHere is a classic example of how to ruin your cache — add a timestamp at the beginning of the agentic prompt and update it every cycle. While the data in the prompt mostly remains the same, the cache is constantly invalidated. For you, that means paying the input token price for something that has already been cached.\n\nCached input tokens are the cheapest tokens you spend, but remember that you pay the cached price over and over again during the loop, because the agent keeps sending the full context every time.\n\nFinally, the data reaches the LLM and enters its own loop: the “generation loop.” This is when “output” tokens are generated. The model takes the whole tokenized context and predicts the next token then sends the old context plus the new token to itself and predicts the next one, and so on.\n\nYou are charged here for the newly generated output tokens (only once, with no repeated billing here) and also for what are called “reasoning tokens”. These are basically the same as output tokens, but they are technically not needed for the end user and required by the model itself.\n\nSome providers, especially local AI tools, allow you to turn the reasoning capability off completely, which makes the model a bit more deterministic, but also less advanced. Reasoning tokens can also be completely hidden from user output. This is why they sometimes exist as a separate line item in telemetry and billing, but at other times are simply added to the output. For the sake of this discussion, we’ll consider reasoning tokens the same as output ones.\n\nOutput tokens are the most expensive ones — they are normally 5–6x more expensive than input tokens (or 50–60x more expensive than cached ones).\n\nWhen the model completes its generation loop, the data is sent back to the agent. It contains the messages you see in the chat, file edits, and requests for new tool calls. This data is passed to the agent, which executes the instructions and assembles new context — and so the loop continues.\n\nSince the system always adds new data to the existing context, at some point its volume can exceed the context window size. What happens in this case is called “compaction”. When the agent notices that the context is getting close to its limit, it sends instructions to the LLM to summarize existing information, or to “compact” it. This greatly reduces the current context, usually by 10x. In this case, on the subsequent request the cache is invalidated. What you will see in your telemetry is the cache and context suddenly becoming much smaller and then starting to grow again.\n\nTo summarize the previous section: there are several different types of tokens and they are priced differently. The ratios among cached, input, and output token prices are relatively stable across providers — 1:10:50 or 1:10:60. The table below shows pricing as of July 2026 for several top LLMs, and all of them follow roughly the same ratio.\n\nHowever, the listed price is not all that matters. Coding agents also have a very particular token-volume pattern: input tokens greatly outnumber output tokens, and cached tokens dominate anything else. This is due to extensive use of caching during agentic loops. So while cached tokens are the cheapest, cumulatively they may end up being the largest entry in your bill.\n\nAgain, this trend repeats across different LLM providers and coding agents and their various combinations. This is especially noticeable if you look at [Artificial Analysis data that benchmarks token usage by type ](https://artificialanalysis.ai/agents/coding-agents?coding-agents-token-usage-chart=token-usage#coding-agents-token-usage-chart-tabs)across different LLMs and coding harnesses. Here is a simple infographic based on its data for OpenAI, Anthropic, and Google’s latest LLMs as of July 2026.\n\nThis pattern is not necessarily the same for other AI applications. For example, chatbots or RAG systems can have a very different footprint. There is not enough industry research on this topic, but here is some anecdotal evidence. My personal coding agent usage aligns very strongly with the chart above, while my two AI apps — a chatbot and an AI-driven game — show very different patterns. So, understanding the token-usage pattern for your particular application is critical, but for coding agents you can rely on the existing industry trends.\n\nBut what does this all mean for people who are using AI subscriptions for their coding agents? Can you prevent a “running out of tokens” situation by managing your tokens better?\n\nUnfortunately, providers like OpenAI and Anthropic don’t publish “token allowances”. I am personally using a GPT Plus subscription, and all I can see is how fast my tokens deplete in the 5-hour window.\n\nTo understand my token flow and consumption, I had to rely on the IDE-provided telemetry (in my case, OpenCode Desktop) and build my own tooling around it. Looking at the telemetry, I can see that the tokens fully deplete after about 100K output + 1.4M input + 12M cached tokens. It’s unclear which of those token types, if any, is used as a token budget meter, but it’s a good approximation for me.\n\nOnce you start using credits after depleting your subscription tokens, you may get more API-like telemetry from the providers and see billing for each token type separately.\n\nThe industry is moving toward tokens being the main billable items for AI workflows, but at the same time, the monitoring and reporting of the token spend are still very basic — both on the server/provider and client/IDE sides. If you are switching between multiple providers, deploying a good token monitoring system becomes crucial for understanding your costs and keeping them under control.\n\nAI budgets are not driven by model pricing alone. The cheapest token category can still become a major budget line simply because it repeats in every iteration of the agentic loop. Cached tokens are the clearest example: they are discounted, but they can dominate total usage volume. For business leaders, this means vendor negotiations should focus not only on token prices but also on volume commitments and reporting by token category. For engineering teams, the goal is to understand which workflows generate the largest token volumes and why.\n\nLLMs define token pricing, but coding agents heavily influence volume — how many times you pay that price. Two agents using the same model can have very different cost profiles depending on how they use tools, manage context, and follow instructions. Choose and configure coding agents with the same care as when choosing an LLM provider.\n\nThe information in this article can help you understand your bill and your token spend, but what about forecasting future usage? Any organization would prefer to avoid the kind of Uber situation mentioned in the intro and set a more realistic AI budget.\n\nTelemetry is essential to answer this question — without it, there is no way to compare the estimates with reality. But it’s definitely not enough.\n\n“Can I predict my own token usage?” is the question I’ll explore in depth in the next article, so stay tuned.\n\n[Understanding the cost of coding agents](https://pub.towardsai.net/understanding-the-cost-of-coding-agents-9f4dc0f1e25e) was originally published in [Towards AI](https://pub.towardsai.net) on Medium, where people are continuing the conversation by highlighting and responding to this story.", "url": "https://wpnews.pro/news/understanding-the-cost-of-coding-agents", "canonical_source": "https://pub.towardsai.net/understanding-the-cost-of-coding-agents-9f4dc0f1e25e?source=rss----98111c9905da---4", "published_at": "2026-07-14 20:01:01+00:00", "updated_at": "2026-07-14 20:23:32.241529+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "ai-infrastructure", "ai-products", "developer-tools"], "entities": ["Uber", "Claude Code", "GitHub", "Copilot", "Microsoft", "Anthropic", "OpenAI"], "alternates": {"html": "https://wpnews.pro/news/understanding-the-cost-of-coding-agents", "markdown": "https://wpnews.pro/news/understanding-the-cost-of-coding-agents.md", "text": "https://wpnews.pro/news/understanding-the-cost-of-coding-agents.txt", "jsonld": "https://wpnews.pro/news/understanding-the-cost-of-coding-agents.jsonld"}}