Skip to main content

Token Economics: The Discipline That Decides Whether Your Agent Ships or Gets Shut Down

Agent systems don't usually die because they're wrong. They die because they're wrong about money. Token economics — budgeting, caching, batching, and model routing as design decisions — is the part of production AI engineering that finance will audit.

Token Economics: The Discipline That Decides Whether Your Agent Ships or Gets Shut Down

Picture the meeting that, I’d argue, kills more agent projects than any bug. It happens a couple of months after launch, and it isn’t run by engineering. Finance opens a dashboard, points at a line that grew 8x while usage grew 2x, and asks a question nobody in the room can answer: “What are we paying for, exactly?”

The engineers aren’t incompetent — the system works. But nobody designed its cost behavior, so the cost behavior designed itself. Every call to a large language model (LLM) is billed by the token — the small pieces of text the model reads and writes — and an agent makes many such calls for a single task. Token economics is the discipline of deciding what that costs on purpose, before the invoice decides for you. This post is for the engineers and tech leads who run an agent in production, or are about to.

It builds on context engineering, spec-driven development, evals, OpenSpec and durable execution — and it decides whether systems built that way get to keep running in production. If agents themselves are new to you, start with AI agents and tool calling explained from zero.

First, the words

These are the only terms you need to follow this post. Each one is explained again where it first appears.

  • LLM (large language model) — the model that reads text and writes text back; providers sell several, from small and cheap to large and expensive.
  • Token — a small piece of text, a word or part of a word; you pay for every token you send the model (input) and every token it writes (output).
  • Request (model call) — one round trip: your software sends the model some text and gets an answer back.
  • Context — everything sent in one request: instructions, tool descriptions, conversation so far, documents, tool results; the context window is the most the model can take at once.
  • Agent, step, run — an agent is a model that calls tools in a loop until a task is done; each model call is a step, and one whole attempt at a task is a run.
  • Prompt caching — the provider remembers the unchanged beginning of your prompt, so sending it again costs much less.
  • Batch processing — sending work nobody is waiting for to be processed later, at a discount.
  • Model routing — choosing, for each step, which model handles it: a cheap one or an expensive one.

Why do agent costs explode when request costs don’t?

Because agents multiply. Providers bill every request for the tokens it sends and the tokens it gets back. A chat feature costs roughly one model call per user action — linear, boring, safe. An agent takes steps, and each step can carry the accumulated context of every step before it. Cost per run isn’t step-cost × steps; it’s closer to step-cost × steps², because the context window grows as the run gets longer. Add retries (re-running a step that failed), tool-result payloads dumped verbatim into context, and a planner that “thinks about it one more time,” and an 8x cost surprise on 2x usage stops being mysterious.

This is why token economics is inseparable from context engineering (deciding everything the model sees at each step). Every context-engineering decision — what to retrieve, what to summarize, what to evict (drop from the context) — is also a purchasing decision. A sloppy context strategy isn’t just a quality problem; it’s a standing order to buy the same tokens over and over.

The durable-execution connection is just as direct: an agent that can resume instead of restart doesn’t re-buy its own history after every failure. In cost terms, checkpointing — saving progress at points a failed run can resume from — is a discount program. Retry-from-zero architectures pay full price for the same work N times and call it reliability.

What is token economics?

Token economics is the engineering discipline of treating LLM cost as a designed property of the system rather than a discovered one. It covers four core decisions: what each request is allowed to cost (budgeting), what work you refuse to pay for twice (caching), what work can wait for cheaper processing (batching), and which model earns each request (routing). Teams that make these decisions explicitly ship agents with predictable unit costs (the cost of one completed task); teams that don’t find out their unit costs from the invoice.

The word “economics” is doing real work in that definition. This isn’t cost cutting — it’s cost modeling: knowing the marginal cost of one more user, one more feature, one more agent step, before finance asks.

Nobody designed its cost behaviour, so the cost behaviour designed itself. That sentence is, I’d argue, the usual story behind an agent system that gets shut down over cost.

Those four decisions, plus two levers borrowed from neighbouring disciplines — checkpointing and context eviction — give six levers. They are worth knowing as a set, because each one has a failure mode that shows up as a cost surprise rather than an error; the sections below take them one at a time, and a table at the end puts all six side by side.

What should a token budget actually look like?

A real token budget is a per-request ceiling with an owner and an enforcement point, not a monthly total on a dashboard. The working form: each feature declares its expected cost per request and its hard maximum, the system enforces the maximum at runtime (while the agent is running — an agent that hits its ceiling stops and reports, exactly like a timeout), and someone named owns the number. Monthly totals discover problems; per-request ceilings prevent them.

Budgets change engineering conversations in a way dashboards never do. “Can we add a verification step to the agent?” stops being a philosophical debate about quality and becomes arithmetic: the step costs ~4,000 tokens per run, the budget has 3,000 of headroom, so either the step gets cheaper or something else does. That’s a productive argument. Teams have it before shipping instead of after the invoice.

The budget also has to be visible in the same place the spec lives. If you practice spec-driven development (writing a checkable description of what the software must do before an agent writes the code), the cost ceiling belongs in the spec next to the behavioral requirements — “answers within 30 seconds, costs under X per run” — because a requirement nobody wrote down is a requirement the system doesn’t have.

What does caching buy you, really?

Prompt caching is the highest-leverage cost tool in the stack because agent workloads are extraordinarily repetitive: the system prompt (the standing instructions), the tool schemas (each tool’s description and inputs), and the long-lived context are identical across steps and often across users. Cache-aware request design — stable prefix (the unchanging beginning of the prompt) first, volatile content last — can cut the input cost of an agent system substantially, with no quality tradeoff whatsoever: cached tokens are still billed, but at a fraction of the normal input price (on Anthropic’s API, as of November 2026, a cache read costs a tenth of the base input price or less, while writing the cache costs somewhat more than a normal input token; on cloud platforms such as Amazon Bedrock the cache rules can differ — see Running Claude on AWS). It’s the closest thing to free money in AI engineering.

A worked example (illustrative numbers, prices only as multiples of the base input price). Say one agent run makes 20 model calls, and each call starts with the same 10,000-token prefix of instructions and tool schemas:

  • Without caching: 20 calls × 10,000 tokens = 200,000 tokens, all at the full input price.
  • With caching: the first call writes the cache — 10,000 tokens at somewhat more than the full price. The other 19 calls read it at a tenth of the price or less: 19 × 10,000 × 0.1 = 19,000 full-price equivalents. Total: a little over 29,000 full-price equivalents instead of 200,000 — roughly a seventh of the cost of the prefix.
  • With caching silently broken (the timestamp mistake described below): back to 200,000, about seven times the cached cost, and nothing errors.

The exact ratio depends on how many calls share the prefix and how long the prefix is; the part that grows step by step, and the output tokens, are billed separately. But the shape holds: the more calls reuse the same beginning, the more caching is worth — and the more it costs you when it quietly stops working.

But caching only pays if requests are built to be cacheable, and that’s an architecture decision, not a flag. A prompt assembled in a different order per request defeats the cache silently — you pay full price and nothing errors. This is a place where the difference between “read the API docs once” and “actually knows the platform” shows up directly on the invoice; the mechanics (cache breakpoints, which mark where the cacheable part ends; prefix design; TTLs, or time-to-live; and how to verify you’re getting cache hits) are exactly the kind of thing the Claude API course drills, because verified savings beat assumed savings.

Designing a request that can actually be cached

The rule is simple to state and easy to violate: everything stable goes first, everything volatile goes last. System instructions, tool schemas, and long-lived project context form the prefix; the user’s current message, retrieved chunks (the document passages found for this query), and step-specific state come after. The moment one varying token appears early, everything after it becomes uncacheable — the cache matches on prefixes, not on content it recognises later.

A classic self-inflicted wound is a timestamp. Someone adds a helpful Current time: … line near the top of the system prompt, and the entire prefix changes on every single call. The prompt still works. The evals still pass. The bill quietly climbs, and there is no failure anywhere to investigate. The same goes for a user’s name, a request ID, or a randomly-ordered set of tool definitions assembled from a hash map (a structure that does not keep a fixed order) — anything that varies per call belongs after the stable block, or nowhere.

Cache lifetime matters too. Cached prefixes expire, so a low-traffic feature may pay to write the cache and never read it before it lapses; a high-traffic one spreads the cost of the write across thousands of calls. This is why caching wins so decisively on agent loops specifically — a single run makes many calls in quick succession against an almost identical prefix.

Verifying the savings instead of assuming them

Log cached and uncached input tokens as separate fields, always. A dashboard showing one merged “input tokens” number cannot tell you whether caching is working, and a team can go on believing it is getting a discount it stopped getting weeks ago. With the split recorded, the derived metric you actually want is a cache-hit ratio per feature (the share of input tokens served from the cache), and the alert you want is a drop in that ratio — because the thing that breaks caching is never a deploy labelled “break the cache,” it’s an innocuous refactor that reordered how the prompt gets assembled. That alert is the difference between finding out in an afternoon and finding out in a quarterly review.

What work can wait for a cheaper price?

Batching is caching’s quieter sibling: any work that doesn’t need an answer in seconds — nightly summarization, backfills (re-processing old data in bulk), eval suites (sets of repeatable tests that score the system’s outputs) — can run through batch processing at a steep discount. The design question is simply which of your workloads are secretly asynchronous, meaning nobody is waiting on the answer. In my experience it’s more of them than the architecture admits, evals being the canonical example: a comprehensive suite run nightly at batch prices costs less than a thin one run synchronously in panic after an incident.

When should a smaller model take the request?

Route by verifiability, not by vibes: use the smallest model whose output you can check, and reserve the frontier model (the most capable and most expensive one a provider sells) for steps where being wrong is expensive and checking is hard. Classification, extraction, formatting, summarization-for-storage — these have verifiable outputs and tolerate a cheaper model backed by validation (a mechanical check of the output, such as “is this one of the allowed labels?”). Planning, tool selection in open-ended situations, and final user-facing synthesis usually earn the big model. A well-routed agent often runs most of its steps on small models while spending most of its tokens where quality actually binds.

Routing is also where evals stop being optional. Without a regression suite (tests that catch what used to work and stopped), every routing change is a leap of faith, and teams either never optimize (expensive) or optimize blind (worse). With a real eval harness, “move extraction to the small model” is an afternoon’s experiment with a pass/fail answer. The eval suite is what makes cost optimization safe: spec says what must hold, evals verify it still does, and token economics decides what it may cost.

The pattern that beats both extremes is escalation rather than assignment: run the step on the small model, validate the output mechanically, and retry on the frontier model only when validation fails. If the cheap model is right eighty percent of the time and validation is reliable, you pay small-model prices four times out of five and still get frontier-model correctness — better economics than routing everything down, and better quality than routing everything up.

There is a third shape. In the advisor pattern, a smaller model runs the whole task end to end and consults a larger model only at hard decision points — Multi-Agent Systems in 2026 describes it. Routing by step, escalation on failed validation, and an advisor are options, not rival doctrines; the per-model advice you’ll see elsewhere on this blog (Sonnet by default, Opus for hard reasoning, Haiku for high-volume classification) is a starting point. Which shape wins on your tasks is an eval question.

A concrete shape — take a support-triage agent (one that sorts incoming support requests) as an illustration: classify the incoming request (small model, output is one of a fixed set of labels, trivially checkable), retrieve the relevant history (no model at all — this is a database query that is all too easy to hand to an LLM for no reason), draft the response (mid-tier), then final-check for policy and tone before it reaches a human (frontier). Four steps, three different models, one step with no model. Most of the steps run cheap; most of the tokens land on the two that matter.

The anti-pattern worth naming: routing by customer tier instead of by task. Paying customers do not need a bigger model, they need a correct answer — and a cheap model with validation often produces one more reliably than an expensive model with none. Route by verifiability, let the evals decide, and keep the pricing page out of the architecture.

First check that you need several agents at all (a multi-agent system: several agents on one task, with an orchestrator handing sub-tasks to sub-agents): one agent with good tools often does the job for less, and Multi-Agent Systems in 2026 makes that case. If you do run several, add one rule: sub-agents don’t inherit the orchestrator’s model by default. Each role gets the cheapest model that passes that role’s evals — the difference between a fleet that scales and a fleet that gets shut down is usually this rule, applied early. Building agents with per-role model choices and cost instrumentation from day one is a core pattern in the Agent SDK course, for exactly this reason.

How do you make cost visible before finance does?

Instrument cost per request, per feature, and per agent-step from the first deploy — the same way you treat latency (how long a request takes). Log tokens in and out (cached and uncached separately, or you’ll fool yourself), tag by feature and step, alert on per-request outliers rather than monthly totals. One slow query doesn’t wait for the monthly infrastructure review; one 50x-cost agent run shouldn’t either.

Five fields per model call are enough to answer almost every question you will later be asked: feature, step, model, input tokens split into cached and uncached, and output tokens. Everything useful derives from those — cost per run, cost per feature, cache-hit ratio, the distribution that tells you whether your budget ceiling is sized for the average or the tail (the rare, much longer runs). Teams that skip the step tag are the ones who know their agent is expensive but cannot say which of its eight steps is responsible, which turns a one-afternoon fix into a week of guessing.

Then two alerts, and resist adding more. First, a per-request cost outlier — a single run crossing some multiple of its budget, because that is what a runaway loop (an agent that keeps calling the model without converging) looks like from the outside. Second, a drop in cache-hit ratio per feature, which is how the silent cache miss announces itself. Monthly-total alerts feel responsible and are nearly useless: by the time a monthly number is alarming, the money is spent and the cause is four deploys back.

The reporting artifact that changes the politics is the unit-cost curve: cost per successful task over time. It reframes the finance meeting from “why is the bill growing” (a threat) to “unit cost fell 40% while usage doubled” (a victory lap). Same numbers, opposite meeting — and the team that owns its unit costs gets to keep experimenting, because leadership trusts the meter is being watched.

The discipline, compressed

Here are the six levers side by side — what each does, and the way each one backfires as a cost surprise rather than an error:

LeverWhat it doesTypical effectHow it backfires
Per-request budgetCaps what one run may spend, enforced at runtimeTurns “can we add a verification step?” from a debate into arithmeticSized from averages, so the long-tail runs die at the ceiling instead of finishing
Prompt cachingStops re-buying the stable prefix on every stepLarge cut in input cost, with no quality tradeoff at allA prompt assembled in a varying order misses silently — full price, no error
Batch processingMoves work nobody is waiting for to discounted asyncSteep discount on evals, backfills and summarisationApplied to something a user is waiting for, and now the feature feels broken
Model routingSends each step to the cheapest model whose output you can verifyMost steps get cheap; tokens concentrate where quality bindsDone without evals, so you optimise blind and ship a quality regression
CheckpointingLets a failed run resume instead of restartRetries stop re-buying the whole conversation historyCheckpoints too coarse, so you replay most of the run anyway
Context evictionDrops what the next step demonstrably doesn’t needStops cost growing quadratically with run lengthEvicts the one constraint the agent needed to keep obeying

Give every request a budget with an owner. Build prompts to be cached, and verify the hits. Batch everything that’s secretly asynchronous. Route by verifiability, with evals as the safety net. Checkpoint so retries don’t re-buy history. Instrument unit cost from day one, and report it before you’re asked. None of this is exotic — it’s the same maturity curve infrastructure cost went through a decade ago, compressed into a year. The teams that internalize it get to run ambitious agent systems; the teams that don’t get the meeting. The RAG-and-agents architecture patterns (RAG: retrieval-augmented generation, answering from documents the system looks up first) all assume this discipline underneath — and if you want the operating model behind all of this, spec-driven development foundations is where spec, context and evals get assembled into one workflow.


Related in this series

Share this article
X LinkedIn
Next step

Turn this into a real skill

A structured path from theory to production code — projects and code reviews included.

Oleksii Anzhiiak

Written by

Oleksii Anzhiiak

Software Architect, Senior .NET Engineer & Co-Founder

Oleksii Anzhiiak is a Software Architect, Senior .NET Engineer, and Co-Founder of ToyCRM.com and ProfectusLab. With over 15 years of experience, he specializes in distributed systems, cloud infrastructure, high-load backend development, and identity platforms. Oleksii designs complex architectures, builds secure authentication systems, and develops modern engineering education programs that help students achieve real career results.

LinkedIn

Recommended Watching

Hand-picked third-party videos related to this topic. Open on YouTube.

~8:00:00
Intermediate AI Engineer (AI Engineer World's Fair)

AI Engineer World's Fair 2024 — Keynotes & CodeGen Track

The keynote stream from the largest technical AI conference of 2024. A snapshot of the state of AI engineering — what shipped, what worked, what didn't — straight from the teams building it.

~6:00:00
Intermediate AI Engineer (AI Engineer World's Fair)

AI Engineer World's Fair 2025 — Day 1 Keynotes & MCP Track (ft. Anthropic MCP team)

The MCP track keynote with the Anthropic team. If you want to understand why MCP became the industry-standard protocol for connecting LLMs to tools in 2025, this is the single best primary source.

~2:00:00
Intermediate AI Engineer (Thariq Shihipar, Anthropic)

Claude Agent SDK — Full Workshop (Thariq Shihipar, Anthropic)

A hands-on workshop from Anthropic on building production agents with the Claude Agent SDK — tool use, sub-agents, hooks, MCP servers, and the patterns that scale beyond the demo.

Contact us