DEV Community

Cover image for Token Budgets Paper: Affine-Typed Budget Ownership
pueding
pueding

Posted on • Originally published at learnaivisually.com

Token Budgets Paper: Affine-Typed Budget Ownership

What: The Token Budgets paper catalogs 63 real LLM-agent cost-overrun incidents and ships a Rust crate that models a token/cost budget as an affine-typed (use-at-most-once) resource the compiler tracks.

Why: Cost is a production failure mode, and the paper finds it's multi-agent delegation — not single agents — that drives the overruns: fan out work to parallel sub-agents and each one quietly reserves budget against a cap nobody is decrementing.

vs prior: Versus a runtime budget guard — an assert that fires at spend time, after the tokens are already committed — affine typing makes an overrun a compile-time error, so the unsafe code path can't ship in the first place.

Think of it as

One prepaid gift card a group splits at dinner.

                  ONE $1,000 GIFT CARD
                          │
          ┌───────────────┴───────────────┐
          │                               │
  ┌───────▼───────┐               ┌───────▼───────┐
  │  PHOTOCOPY IT │               │   SPLIT IT    │
  │ (static copy) │               │ (affine move) │
  └───────┬───────┘               └───────┬───────┘
          │                               │
 4 copies x $350 each         $300+$220+$260+$220
 nobody debits the card       money moves out, no copy
          │                               │
          ▼                               ▼
   ✗ bill = $1,400               ✓ total = $1,000
     over a $1,000 cap             bounded to the cap
Enter fullscreen mode Exit fullscreen mode
  • token budget = the card's balance ($1,000)
  • sub-agent = a friend who wants to spend
  • static reservation = everyone photocopies the card and assumes the full balance
  • overshoot = four copies each spend $350 — the bill hits $1,400 on a $1,000 card
  • affine ownership = split the card into prepaid sub-cards — money moves out, can't be photocopied

Quick glossary

Token / cost budget — A hard cap on how many tokens (and therefore dollars) one agent task is allowed to spend. Where those tokens go is the first thing a production agent has to account for.

Affine type — A type that may be used at most once. The compiler tracks the value's ownership, so you can move or split it but never copy it — exactly the property a budget needs.

Delegation fan-out — When an orchestrator hands a task to several sub-agents running in parallel. Each child needs some budget, and the question is who keeps the shared total honest.

Static vs adaptive reservation — Static reservation grabs a fixed slice up front and over-provisions 4–6×; adaptive reservation re-estimates per call and over-provisions 2.11× — fewer wasted tokens, but still a runtime accounting trick.

Compile-time vs runtime check — A runtime check tests the budget while the agent runs (too late to un-spend); a compile-time check rejects the unsafe program before it ever runs. Affine typing moves the cap into the second category.

Cohen's kappa — An inter-rater agreement score (1.0 = perfect). The paper's 8-category failure taxonomy reaches 0.837, i.e. two independent reviewers classified the incidents almost identically.

The news. On June 2, 2026, the Token Budgets paper landed: an empirical catalog of 63 production cost-overrun incidents in LLM-agent systems, pulled from a review of 21 orchestration frameworks spanning 2023–2026 and clustered into an 8-category failure taxonomy (inter-rater Cohen's kappa 0.837). As a mitigation, the authors ship a 1,180-line Rust crate that uses affine-type ownership to turn budget violations into compile-time errors. In controlled tests, single-agent runs never overshot (0/30) while multi-agent asyncio delegation overshot every time (30/30); the mitigated runs then logged 0 cap violations across 160 live-API tests. Read the paper →

Picture the group dinner. There's one prepaid gift card with $1,000 on it, and four friends who all want to order. The cheap, lazy move is for everyone to photocopy the card and assume they each have the full balance — four copies, four people each cheerfully spending $350, and a $1,400 bill arrives against a card that only ever held $1,000. The card was never debited as people spent, so nothing stopped the overshoot until the bill came. Affine-typed budget ownership is the opposite rule: there is exactly one card, and the only legal operation is to split it into prepaid sub-cards — the money physically moves out of the original, and a photocopy simply isn't allowed.

In an agent system the "photocopy" bug is a delegation fan-out: an orchestrator spawns parallel sub-agents, and each one reserves a chunk of the token budget against a cap that no single owner is decrementing. The paper's headline number is that this pattern overshot 30 out of 30 runs, while a single agent — which spends against one running total — overshot 0 of 30. The fix is to make the budget an affine value: the Rust compiler tracks it as use-at-most-once, so a code path where two sub-agents could both hold the same budget fails to type-check. The cap is enforced by construction rather than by an assert that fires after the tokens are already gone — the same shift from runtime to compile-time that separates a retry loop that quietly re-bills you from one that can't.

Where the budget actually goes

A back-of-envelope walk-through (illustrative cap and slice sizes; the overshoot and over-reservation counts are the paper's). Say the shared cap is 1,000 tokens and the orchestrator fans out to four sub-agents. Under static reservation each child grabs a fixed 350, and because the reservations are effectively copies, the total claimed is 4 × 350 = 1,400 — a 400-token (40%) overshoot that nothing rejects until the spend lands. Make the budget affine and the same 1,000 is split into owned slices — say 300 + 220 + 260 + 220 = 1,000 — where the fourth claim can only take what the first three left behind. The sum is bounded to the cap by construction, which is the property the paper's Rust crate enforces: across 160 live-API tests it logged 0 cap violations, where unbounded multi-agent delegation had overshot all 30 runs. Static reservation's habit of grabbing 4–6× the budget it needs (adaptive trims that to 2.11×) is the same waste, viewed from the other side.

Approach When the cap is checked Multi-agent overshoot Over-reservation
Runtime budget guard at spend time — after tokens commit possible (the default failure)
Static reservation up front, no shared cap 30/30 runs (Token Budgets paper) ~4–6× (paper)
Adaptive reservation re-estimated per call not reported (paper) ~2.11× (paper)
Affine-typed ownership compile time — won't type-check 0 violations / 160 tests (paper) bounded to the cap

The catch is that this only buys you safety where you can express ownership in the type system — a Rust crate gets it for free, a Python orchestrator built on asyncio.gather does not, which is exactly where the paper's 30/30 overshoots came from. But the lesson generalizes past the language: in a multi-agent team the budget is a shared resource, and who is allowed to hold it, and whether they can copy it, is a design decision — not something to discover when the bill arrives.

Goes deeper in: Agent Engineering → Cost & Latency Engineering → Where the tokens go

Related explainers

FAQ

What is affine-typed budget ownership?

It models an agent's token or cost budget as an affine-typed value — one the compiler allows you to use at most once. You can split the budget into smaller owned slices or move it to a sub-agent, but you can't copy it, so two parts of the system can never both spend against the same cap. The Token Budgets paper implements this in a Rust crate and reports 0 cap violations across 160 live-API tests.

Why do multi-agent systems overshoot their token budget?

Because delegation fans the work out to parallel sub-agents that each reserve budget against a cap no single owner is decrementing. The reservations behave like copies, so their sum can exceed the real limit. In the paper's controlled tests, multi-agent asyncio delegation overshot 30 of 30 runs while a single agent — spending against one running total — overshot 0 of 30.

How is a compile-time budget check different from a runtime guard?

A runtime guard (an assert or limiter) checks the budget while the agent runs, which is too late to un-spend tokens already committed. A compile-time check rejects the unsafe program before it runs: with affine typing, a code path where two sub-agents could hold the same budget simply fails to type-check, so the cap is enforced by construction rather than by hoping the guard fires in time.


Originally posted on Learn AI Visually.

Top comments (0)