The first time I let an agent loop freely on a real task, it happily spent its way through my budget re-reading the same files and second-guessing itself. That was the day I decided cost is a feature, not an afterthought — and I built it into the Avni Skills SDK from the ground up.
The SDK is a chat-driven tool for authoring Avni implementation bundles: a deterministic generator wrapped in a Claude-Agent loop where every turn is a git commit. Agents are powerful there — and exactly the kind of thing that quietly burns tokens. So I gave every session a wallet.
Three limits, one wallet
- ▸Per-session cap: $5. A single authoring session physically cannot spend more than five dollars. When it hits the ceiling, it stops.
- ▸Per-turn cap: $1. No single instruction can blow the budget in one shot. A runaway turn is contained to a dollar.
- ▸A thrash-detector. If the agent burns 3,000+ output tokens without actually editing a file, it's spinning — so the loop aborts it. Thinking is fine; thrashing is not.
The payoff is boring in the best way: a typical build lands at about $0.13, and the dashboard shows a live wallet gauge ($0.3955 / $5.00) so you always know where you stand. Predictable cost is what lets you actually put an agent in front of non-engineers.
You can't ship GenAI you can't afford to run. Token economics is a design constraint, not a billing surprise.
Why this matters for production
Most agent demos ignore cost because the demo is cheap. Production isn't a demo. The moment real people use your agent, unbounded loops become unbounded invoices. Capping spend per session and per turn — and detecting the specific failure mode of expensive indecision — is the difference between a tool you can hand out and a science experiment you have to babysit.
It's all open source. If you want to see how the caps and the thrash-detector are wired, the code is on GitHub.