Skip to content
PKResources
Course outline

The CTO's playbook for AI coding agents · Module 5: Token economics

What drives AI spend: tokens, loops and the hidden multipliers

One agent task is never one model call. Learn the handful of drivers behind your AI bill so you can read an invoice, spot the outliers and ask the right questions.

Lesson 17 / 20 · ⏱ 8 min

Chat assistants trained everyone to think of AI cost as “a few cents per question”. Coding agents break that intuition. An agent is a model in a loop, and every turn of the loop is a paid call that resends most of what came before. Your bill is the product of a few multipliers, and you can only manage what you can name.

One ticket, many calls

1 taska ticketPlanread the brief, outlineExploresearch, open filesEdit and testpatch, run, retryCI review agentruns on every push2 calls6 calls8 calls2 are retries3 callsabout 19 paid calls for one ticketretry after a failed test
Illustrative: one ticket fans out into about 19 model calls. Bar height is the tokens sent in that call, which keeps growing because the context is resent every turn.

The person who filed the ticket sees one change. Finance sees nineteen calls, the later ones much bigger than the first. That gap is why per-seat intuition fails for agents.

The six drivers

Driver What it means Why it multiplies
Input tokens Everything sent to the model: instructions, files, tool output, history Resent on every turn, so it compounds over a session
Output tokens What the model writes back: plans, code, explanations Pricier per token, but usually far smaller in volume
Context size How much the agent loads before it acts Big repo dumps and long logs inflate every later call
Loop length Number of turns before done or stopped Retries and dead ends add turns that produce nothing
Model tier Small, mid or frontier model Price gaps between tiers are often 10x or more
Background agents CI reviewers, scheduled jobs, triage bots Run on every push or every night, with no human watching

Caching is the counterweight. Many providers discount input that repeats exactly from one call to the next, such as a stable system prompt or a repo instruction file. A setup that keeps its prefix stable can pay a fraction of list price for most of its input.

Who actually spends

Spend is rarely spread evenly. In most orgs a small group of heavy users, plus a couple of always-on automations, produce most of the usage. That is not automatically bad: your heaviest users may be your best. But you can’t tell until you can see usage per person, per team and per automation, which is the subject of the next lesson.

Myths about the bill

🃏 Myth or reality?

Tap a card to flip it

For the developer-level view of context, see the context budget lesson in the Agentic Engineering course, and Loop engineering for how loop design drives turn count.

Before you move on

✅ Key takeaways

0 / 4 completed