Subscribe to Newsletter

Chapter 1: Understand the bill

Explain why a short request can produce a long invoice.

Chapter 1 of 6 · 4 sections

Learning objectives
  • Explain why a thirty-token request can turn into nine model calls and a much larger invoice.
  • Name the five principles that govern AI coding spend, from pricing the whole task to counting accepted output.
  • List the five records you need to reconstruct what one task cost from the first call to the last.
  • Judge a large bill by the session behind it instead of by the engineer who triggered it.
1.1

Why a short request can produce a long invoice

You approve a coding assistant for a team of 100. A month later the bill has doubled, and headcount has barely moved. Finance wants a limit. Engineers want to keep the tool.

Uber lived this at scale. Agentic tools reached about 5,000 engineers in late 2025, and by April 2026 the CTO said the year’s budget was already gone. By June, every employee was capped at $1,500 a month per tool.

Before you reach for a limit, ask a better question: what changed inside the work? Maybe more people are using the tool. Maybe tasks are running longer. Maybe a new default model costs more per token. Those are three different problems, and one blanket restriction treats them as the same one.

1.2

A prompt starts a loop

A coding agent is a model wrapped in software that can read files and run tools. That surrounding software is called a harness. A token is the small unit of text that providers use to meter what goes into a model and what comes out.

The agent works in a loop. It takes a step, looks at the result, and decides what to do next. Each new call can carry the earlier instructions and tool results along with it, so the context keeps growing as the task goes on.

The illustration below shows that growth through one task. Real tools trim and summarize some of it, and cached context is cheaper, but all of it still lands on the bill.

ONE TASK, ONE AGENT LOOP 30 TOKENS “investigate and fix this bug” Load instr.& tools Search repo Read files Plan Edit Run tests Read failure Retry Review diff CONTEXT CARRIED INTO EACH CALL Carried forward: system prompt, tool schemas. Carried forward: system prompt, tool schemas, prior turns. Carried forward: system prompt, tool schemas, search results, prior turns. Carried forward: system prompt, tool schemas, file contents, prior turns. Carried forward: system prompt, tool schemas, file contents, plan, prior turns. Carried forward: system prompt, tool schemas, file contents, diffs, prior turns. Carried forward: system prompt, tool schemas, file contents, diffs, test logs, prior turns. Carried forward: system prompt, tool schemas, file contents, diffs, logs, failure, prior turns. Carried forward: system prompt, tool schemas, file contents, logs, every prior turn. The 30 tokens the developer typed. WHAT THE DEV TYPED WHAT GETS BILLED Sum of every call: the prompt plus all the context carried forward, turn after turn. SUM OF ALL CALLS
Scroll sideways →Source: Databricks.

A large invoice is a symptom, not a verdict. Look at the session before you judge the engineer. An expensive migration can be excellent value. A cheap retry loop that never ships anything is pure waste, and the two can cost about the same.

1.3

Five principles to keep in view

  1. Price the whole task. A cheap call can start an expensive sequence.
  2. Make models earn their place. Test them on your own work before you adopt them.
  3. Route routine work deliberately. Decide in advance when a stronger model should take over.
  4. Give daily and monthly budgets separate jobs. Catch accidents fast, and approve sustained spend on purpose.
  5. Pay attention to accepted output. Tokens measure what you consumed. Finished work is what earned the spend.
1.4

Follow one task from request to result

RecordWhat it tells you
User, team, task IDWho owns the work and which outcome the bill belongs to.
Model and harness versionWhether a change in the tool explains a change in cost.
Input, cached input, output, cache writesWhich billed categories dominate. Use the actual model rates.
Calls, retries, elapsed timeWhether the agent is making progress or repeating itself.
Accepted result and reworkWhether the task met the quality bar and what humans had to repair.
MAKE THE CALL · 1 / 5

Find the expensive part

A developer sends a 30-token request. The agent makes nine model calls as it reads files and retries a failing test. Which number should you investigate first?

Choose an answer. You can retry after reading the explanation.

END OF CHAPTER 1 · PUT IT TO WORK

Trace one task

Pick one task that shipped and one that failed. Reconstruct what each one cost from the first call to the last. If you cannot yet join the calls to the task, that is your first measurement gap, and it comes before anything else in this guide.

Key terms

Harness
The software wrapped around a model that lets it read files and run tools.
Token
The small unit of text providers use to meter what goes into a model and what comes out.
Agent loop
The cycle where the agent takes a step, looks at the result, and decides what to do next.
Carried context
The instructions, tool schemas, and prior turns sent again with each new call, which is why context grows through a task.

Further reading

  1. DatabricksManaging AI coding costs at scale

    The source behind the context-growth diagram in this chapter.

  2. TechCrunchUber caps employee AI spending after blowing through budget in four months

    The cap this chapter opens with, and what preceded it.