Token Budgets: An Empirical Catalog of 63 LLM-Agent Budget-Overrun Incidents, with an Affine-Typed Rust Mitigation as a Case Study
This paper presents an empirical catalog of 63 LLM-agent token budget overruns and introduces "token-budgets," a type-safe Rust crate that leverages affine ownership to enforce non-bypassable spending limits at compile time, effectively preventing delegation-related cost explosions that plague ad-hoc runtime solutions.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
The Problem: The "Infinite Money Glitch" in AI
Imagine you hire a robot assistant to do some work for you. You give it a strict rule: "Spend no more than $10 on my credit card."
However, the robot gets confused. It gets stuck in a loop, trying to solve a problem over and over again. Because the robot doesn't have a built-in "stop button" that checks the price before it makes a call, it keeps spending. By the time you wake up the next morning, the robot hasn't just spent your $10; it has spent $10,000.
This paper calls this a "Budget Overrun." The authors found 63 real-world examples of this happening between 2023 and 2026 across many different AI frameworks. In some cases, users lost thousands of dollars because the software didn't stop the spending before it happened.
The Current Fixes: The "After-the-Fact" Alarm
Most companies currently try to fix this by putting up a "security guard" who watches the spending after the robot has already made the call.
- The Analogy: Imagine you go to a store, buy 1,000 items, and then the cashier stops you at the door and says, "Whoa, that's over your limit!" You still have to pay for the items you already grabbed, or you have to run back to the shelf to put them all down.
- The Paper's Point: These current fixes are too slow. They catch the mistake, but they don't prevent the damage.
The New Solution: The "Magic Wallet" (Token Budgets)
The authors built a new tool called Token Budgets (written in a programming language called Rust). Instead of a security guard watching the spending, they changed the wallet itself.
The Analogy:
Imagine you give the robot a physical wallet containing exactly $10 in cash.
- No Copying: The wallet is made of a special material that cannot be photocopied. The robot cannot make 100 copies of the wallet to spend $1,000.
- No Double-Spending: Once the robot takes a $1 bill out to buy something, that bill is gone. It cannot put the same bill back in its pocket and spend it again.
- No Sharing: If the robot splits the wallet into two smaller wallets to give to two helpers, the original wallet disappears. The helpers can't go back to the original wallet to get more money.
In the world of computer code, this is called "Affine Ownership." It forces the computer to check the rules before the robot even leaves the house. If the robot tries to break the rules (like copying the wallet), the computer refuses to let the program run at all. It's like a bouncer at a club who checks your ID before you even enter; if you don't have it, you never get to the bar to order a drink.
What They Actually Proved
The paper makes three main claims, which they tested carefully:
- The Catalog of Failures: They created a "Hall of Shame" listing 63 specific incidents where AI agents went on spending sprees. They also found 47 more cases where developers admitted, "We don't have a way to stop this yet." This proves the problem is real and happens often.
- The "Magic Wallet" Works: They tested their new Rust tool against five other popular ways of managing AI costs.
- The Result: When they tried to trick the system into spending too much (by creating a race condition where two agents try to spend the same money at the same time), the other systems failed 100% of the time. The new "Magic Wallet" system failed 0 times.
- Why? Because the other systems rely on the programmer remembering to write a "lock" to prevent double-spending. If the programmer forgets, the money leaks. The new system forces the programmer to follow the rules, or the code won't even compile (it won't turn into a working program).
- It's Not a Magic Bullet for Everything: The authors are very honest about the limits.
- It only works in Rust: This specific "Magic Wallet" only works if you are writing your software in the Rust programming language. It doesn't work for Python or JavaScript (though they made a Python version that acts like a normal security guard, not a magic wallet).
- It relies on the AI company: The system estimates how much a task will cost. If the AI company (like OpenAI or Anthropic) charges you more than they said they would, or hides some "thinking" costs, the system might still get confused. It trusts the bill it receives, but if the bill is wrong, the wallet might run dry.
The Bottom Line
This paper says: "AI agents are currently dangerous because they can accidentally drain your bank account. We found 63 examples of this. We built a new tool that uses strict computer rules to make it impossible for the code to accidentally copy or double-spend money. It works perfectly for preventing these specific types of mistakes, but it only works if you are using the Rust programming language and if the AI companies tell the truth about their prices."
In short: They didn't just build a better alarm system; they built a wallet that physically cannot be stolen or duplicated.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.