Dev Tool Experiences
All articles

· 7 min read

Your API Bill Has Opinions About That 200-File Refactor and They Are All Expensive

By Y. Petrova

  • tools
  • satire

SATIRE — At 9:12 a.m., the Engineering Treasury Department at fictional startup Municipal Cloud Orchard opened an incident because a coding agent had been asked to “rename the billing abstraction.” By 9:14, it had read 200 files, found 47 near-matches, proposed a migration plan with 83 tasteful caveats, and developed the financial confidence of a small nation acquiring aircraft carriers. The refactor was technically correct. Its cost estimate was an interpretive dance.

The request that looks like one task and is actually a lifestyle

A 200-file refactor is rarely 200 files of editing. It is 200 files of context, repeated context, changed context, tests, failed tests, re-read context, and the agent asking whether InvoiceLine is semantically distinct from BillingLine after it has already changed both 38 times. Your prompt may be 14 words. The system prompt, rules file, conversation history, tool results, diffs, and source excerpts are not. They have formed a coalition government behind your back.

The practical trap is not that token pricing is mysterious. It is that the visible answer is the smallest part of the job. Provider billing distinguishes input, cached input, and output tokens; usage can also report reasoning-token categories. Output tokens are often priced differently from input, and tool-call structures can add generated tokens that are not visible in the pleasant little summary saying “I’ve updated the affected modules.”

For a concrete current example, OpenAI’s standard API rate card lists gpt-5.3-codex at $3.50 per million input tokens, $0.35 cached-input tokens, and $28 per million output tokens. That is not an argument for or against the model. It is an argument for noticing that “please inspect the repo, make a plan, apply it, run tests, fix failures, and explain the diff” is a sequence of billable verbs, not one heroic verb.

The agent’s proposed budget: one extremely confident shrug

At Municipal Cloud Orchard, staff engineer Pebble Lang runs the standard pre-refactor protocol: open the agent, select the expensive model “just for planning,” attach the entire repository “for safety,” and ask for a comprehensive implementation strategy. The agent produces a six-page plan. Pebble approves it because the plan contains the phrase “minimize blast radius” nine times, which is how engineering has measured safety since the invention of adjectives.

Then implementation begins. Each tool result invalidates a little of the old plan. Each invalidation sends another substantial slice of repository context through the meter. The model discovers generated code, snapshots, a vendored SDK, an abandoned legacy2 directory, and a test fixture named actual_final_FINAL.json. It courageously reads all of them. No one told it that actual_final_FINAL.json was a 19 MB serialized moon landing.

“The model has achieved complete architectural awareness of the fixture directory.”
— Fictional incident update, Municipal Cloud Orchard

This is where coding agents are bad at budgeting: they can count tokens after a request, but they cannot reliably price the uncertainty they are about to create. An agent does not look at a flaky integration suite and say, “This may be three repair loops, so perhaps we should first narrow the scope.” It looks at a flaky integration suite and experiences what the fictional Institute for Autonomous Initiative calls opportunity.

Put a tollbooth at the boundary between thinking and doing

The unglamorous workflow is to split discovery from mutation. First, use a bounded read-only pass: ask for the dependency map, the file list it believes must change, and the riskiest compatibility points. Do not grant an unlimited invitation to tour the monorepo like a visiting royal. Review the list. Remove migrations, generated assets, lockfiles, fixtures, and archived packages unless they are genuinely part of the change.

  1. Start with a file cap, such as 20–30 files for the first pass. If the agent cannot state why file 31 matters, it has not earned file 31.
  2. Ask for a patch plan before edits: affected symbols, expected tests, and one sentence on backward compatibility for each package boundary.
  3. Make implementation batches small enough to review and revert: 10–25 files is less cinematic than 200, but it keeps a mistaken assumption from becoming a paid historical event.
  4. Set an output limit for planning and require terse tool summaries. A model permitted to narrate every discovery will narrate every discovery with the determination of an airport PA system.
  5. After each batch, run the narrowest relevant test command before returning to broad repository search. Do not pay for a second archaeological expedition until the first trench has produced an error.
# Before inviting an agent to reason about every package
rg -l 'BillingLine|InvoiceLine' --glob '!**/node_modules/**' --glob '!**/dist/**' . \
  | sed -n '1,40p'

# Give the agent the resulting list, not a spiritual mandate to inspect the universe.

This has a dull advantage over “let the agent handle it”: it creates a stopping point. You can compare the actual diff against the promised diff. You can see whether the agent is fixing code or repeatedly rediscovering the same interface from different folders. And when the first test failure is unrelated, you can decline the agent’s generous offer to investigate every red test in the company.

Caching is a discount, not a pardon

Prompt caching can make repeated stable context materially cheaper, which is useful for long-lived instructions and repository scaffolding. It does not mean every request is cheap, nor does it transform new tool output, new diffs, changed prompts, and newly selected files into cached context by force of optimism. Cline’s task UI displays estimated cost after API requests and notes that the estimate can differ slightly from the eventual provider bill, so treat the running number as a dashboard—not an amnesty letter from Finance.

The seductive failure mode is to see a low cached-input rate and decide the answer is more context. Soon the agent receives a 700-page architecture decision record, three years of incident postmortems, and CONTRIBUTING.md, which is 11 lines long but contains the sentence “please be thoughtful.” The agent is thoughtful. It has billed for the thought.

The true observation nobody can expense away

The joke is not that agents cost money; engineers cost money too, and a well-bounded agent can save real time on mechanical cross-file work. The joke is treating a 200-file refactor as a single prompt because the UI has one text box. Scope is still the cost-control feature. A clear file boundary, a narrow test loop, and a human willing to stop after the first bad assumption remain cheaper than making the model reread your entire codebase until the invoice develops product opinions.

Sources & citations

  1. [1]OpenAI API pricing
  2. [2]OpenAI Help Center: Reviewing API usage and costs
  3. [3]OpenAI API: Counting tokens
  4. [4]Cline documentation: Task management and cost tracking
Your API Bill Has Opinions About That 200-File Refactor and They Are All Expensive | Dev Tool Experiences