Skip to main content

Databricks

Cost Per Token Is the Wrong Number: What Databricks Learned Running Coding Agents on a Multi-Million-Line Codebase

In short

Databricks found a cheaper-per-token coding model cost more per completed task, and a harness change swung costs by over 2x. Here’s why price per token misleads.

107 views3 min readKainotomic Team

Cost Per Token Is the Wrong Number: What Databricks Learned Running Coding Agents on a Multi-Million-Line Codebase

A coding model with a lower token price can still be the more expensive choice once it runs inside an agent loop. Databricks reached that conclusion while benchmarking coding agents against its multi-million-line codebase. It found that a cheaper-per-token model cost more per completed task, and that changing the agent’s harness shifted task cost by more than 2×.

Why that happens. A model only sees the context its surrounding system chooses to retrieve, keep, summarize, and resend. If that system keeps reloading repository material, or makes the model rediscover the same facts, a cheap model can run up a bigger bill before it produces a usable patch. Think of paying a low hourly rate to a contractor who has to re-read the whole project every morning.

The harness is part of the bill. CAST makes the same argument for large codebases. Its paper says repeated repository exploration and context reloads can consume millions of tokens in a single agent run, and it recommends controls such as token budgets, iteration caps, loop detection, and cost circuit breakers. Those are CAST’s recommendations. The document doesn’t show how much each control saves across different repositories, models, and tasks, or that tighter limits keep quality intact. Some changes really do need broad architectural context.

A separate study points the same way. An arXiv paper, How Do AI Agents Spend Your Money?, reports that agentic coding tasks used roughly 1,000 times the tokens of the chat and code-reasoning workloads it compared. It found input tokens were the main cost driver, that spending on the same task could vary by as much as 30× between runs, and that using more tokens didn’t reliably improve accuracy.

What this doesn’t show. Databricks’ result is specific to its benchmark and its harness setups. It doesn’t prove every cheaper model costs more in every repository, and none of the material names a single best harness, context policy, or token budget. Minimizing tokens isn’t the goal either: an agent with too little context can fail more often, need human rescue, or write changes that don’t fit the codebase.

A better yardstick. The sources support measuring cost per completed task, counting token use, retries, failed runs, and how often the output is actually usable. That needs representative tasks, since a small edit and a cross-service refactor have very different context needs.

Bottom line: Model choice can’t be separated from system design. A low model price can be erased by a harness that keeps sending unnecessary context, and a pricier model can cost less per accepted change if it needs fewer attempts. Databricks’ benchmark doesn’t say which model or design wins broadly. It does show that an agent’s context-management policy belongs on the cost sheet next to the published token rates.

Sources

Topics

  • Databricks
  • CAST
  • Agentic Coding Tasks
  • AI coding agents
View all news