All articles
LLM Economics

The $165K Rewrite: What Bun's 11-Day AI Migration Says About Token Economics

Bun's team compressed a Zig-to-Rust migration estimated at 1-2 years of engineering into 11 days by spending roughly $165K on AI coding agents, one of the clearest public datapoints yet on what large token budgets actually buy.

Jul 14, 2026 · 4 min read
The $165K Rewrite: What Bun's 11-Day AI Migration Says About Token Economics

Key takeaways

  • The Bun JavaScript runtime was migrated from Zig to Rust in 11 days using AI coding agents, at a reported ~$165K in token spend (analysis: The Pragmatic Engineer).
  • The manual alternative was estimated at 1-2 years for a small team, so the token bill replaced a multiple of its cost in payroll, plus the calendar time.
  • The prerequisite was a thoroughly tested codebase: agents need an objective pass/fail signal to iterate against.
  • Token spend at this scale behaves like project capex with fat-tailed per-run costs, so caps and forecasts matter.
  • The coding-model market (Fable, GPT-5.6 Sol, Grok 4.5, Muse) is repricing quarterly, so the same project quotes differently every few months.

What actually happened with Bun's rewrite?

Bun creator Jarred Sumner's team used Anthropic's Fable to migrate the runtime's codebase from Zig to Rust, finishing in 11 days for roughly $165K in token costs, per Gergely Orosz's reporting in The Pragmatic Engineer. The team's own estimate for doing it manually was 1-2 years for a small team. (A wrinkle worth remembering when planning around a single vendor: the writeup was briefly delayed because the tool itself was temporarily under US export controls.)

Is $165K in tokens expensive?

Only if you refuse to price the alternative. Illustratively, say a small team is 3-4 engineers for 1-2 years: at typical fully loaded costs, that lands comfortably above $1M, before counting the opportunity cost of shipping everything else 1-2 years later. Against that, $165K of tokens is not the expensive option. It is the cheap one that happens to arrive as a single alarming invoice.

The framing shift matters: this is not "our API bill went up". It is a project budget line, closer to capex than to a subscription, evaluated on cost per outcome rather than cost per month.

Why did this work for Bun, and why might it fail for you?

Bun's codebase is thoroughly tested. That is the quiet, load-bearing fact. Agents can burn through a migration when every change gets an objective pass/fail from a test suite; they flail when "done" is a matter of opinion. If your coverage is thin, the honest sequencing is: spend tokens writing tests first, then spend tokens migrating.

How should teams budget for agent-scale token spend?

Three practices fall out of this story:

  • Forecast a distribution, not a number. Agent runs have fat tails: retries and loops make p99 runs cost far more than the median. Budget to the tail you can tolerate.
  • Cap per run. A stuck agent loop is a money pump; per-run and per-day ceilings turn a runaway into a retry.
  • Re-quote per project. With Fable, GPT-5.6 Sol, Grok 4.5, and Meta's Muse all competing on coding, price per outcome shifts quarter to quarter. The model that was cheapest for your last migration may not be cheapest for the next.

What does this mean for AI product margins?

The same accounting shift applies inside SaaS products. When a feature triggers agent workflows, its cost is no longer a rounding error in COGS; it is a distribution with a tail. Whether $165K compresses years into days for you, or just compresses your margin, depends on whether you modeled the burst before starting it.

One-line takeaway: agents turn engineering time into a token bill, and a bill you can forecast is a bill you can say yes to. If you want to model an agent-heavy workload, or the margin impact of one, before you run it, Calcaas is built for exactly that math.

Frequently asked questions

How much did Bun's Zig-to-Rust migration cost?

Roughly $165K in AI agent token spend over 11 days, according to reporting in The Pragmatic Engineer. The manual alternative was estimated at 1-2 years for a small engineering team.

Why are AI agent costs so unpredictable?

Agent runs involve retries, tool calls, and iteration loops, so per-run costs have fat tails: a p99 run can cost many times the median. Per-run caps and distribution-based budgets keep this manageable.

What made the AI-driven migration feasible?

A thoroughly tested codebase. The test suite gave agents an objective pass/fail signal to iterate against, which is what allows large autonomous changes to converge instead of flailing.

Should token spend count as COGS or capex?

Recurring, per-user inference belongs in COGS. One-off, project-scale agent bursts like migrations behave more like capex: a discrete investment evaluated on cost per outcome.

ShareXLinkedInFacebook

More from the blog

The Margin Memo

Pricing math, in your inbox.

One short note a week on AI pricing, token economics, and margin. No spam, unsubscribe anytime.