all writing
Cost2026-07-01 · 6 min

Cost-capped agents: shipping an AI SDK with a $5 ceiling

A production agent that can't run away with your money — per-session caps, per-turn caps, and a thrash-detector that kills wasted spend.

by Siddharth Harsh Raj

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

user turn
budget check
$5 / $1 caps
agent loop
thrash guard
3k idle → abort
commit + cost
logged
Every turn passes through the wallet before it runs.

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.


Building something with AI agents?
I'm open to senior remote roles.
Get in touch