Skip to the page

AI agents · intermediate · About 10 minutes

The agent bill that grew 5 times in a month

A coding agent's monthly bill went from $1,200 to $6,700 while the number of tasks rose by a fifth. Find where the money went before you cut the wrong thing.

You look after the team's AI coding agent and its budget.

What happened

Your team uses an AI coding agent to fix failing tests. It reads the code, runs the tests, edits files and runs the tests again until they pass.

The agent's line on the bill was $1,200 in August and $6,700 in September. The team ran about 20% more tasks in September. The model and its price did not change. Finance would like an explanation and a plan by Friday.

The incident is made up. How things work in it is real, with sources at the end.

The evidence

Everything you need is here. Read it before you decide.

01One typical task, August against September(Table)
AugustSeptember
Turns (model calls) per task1240
Conversation size at the first turn20,000 tokens20,000 tokens
Conversation size at the last turn50,000 tokens120,000 tokens
Input tokens processed, whole task420,0002,800,000
Output tokens written, whole task50,00060,000
Input tokens read from cache00

The team's price is $3 per million input tokens and $15 per million output tokens.

02What changed on 1 September(Note)

To help the agent debug, someone changed its setup to paste the full output of every test run into the conversation, not just the failures. A test run prints about 2,500 tokens.

03How the agent calls the model on every turn(Code)
while not done:
    reply = client.messages.create(
        model=MODEL,
        system=AGENT_INSTRUCTIONS,      # same text every turn
        tools=TOOLS,                    # same text every turn
        messages=conversation,          # everything so far, sent again
    )
    conversation.append(reply)
    conversation.append(run_tools(reply))  # test output goes in here

Your decisions

Decision 1 of 2

  1. Decision 1

    Where did the money go?

The ideas behind it

LessonSame price per token, smaller bill: what a job costs

Sources

Where each fact comes from

This page was last checked against these sources on 14 October 2026.

  1. 1
    What a task costs on Opus 5.5

    Anthropic · 14 October 2026

    A task that grows from 20,000 to 120,000 tokens over 40 turns processes about 2.8 million input tokens, though the conversation never grows past 120,000. Each turn sends the conversation so far.

  2. 2
    Prompt caching

    Anthropic, Claude API documentation · 14 October 2026

    Prompt caching covers the prompt in the order tools, system, then messages, up to a marked point. The default cache lifetime is 5 minutes. A 5-minute cache write costs 1.25 times the base input price and a cache read 0.1 times.

  3. 3
    Building effective agents

    Anthropic · 14 October 2026

    An agent is a model using tools in a loop, based on feedback from its environment.