We Gave an AI Agent a Spending Gate It Cannot Break - Then Paid Two Audits to Try
EPIC-265 hacksgiving agent: a Thanksgiving-shopping agent physically cannot overspend - every purchase passes a mandate gate running byte-verified production spend-enforcement code (sha256-pinned, 43/43 conformance), isolated across two Fly.io Sprites, the shop credential existing only inside a connector the agent is policy-denied from touching. First adversarial audit found 2 critical overspend paths (rounding mismatch, client-declared amounts), fixed same-day; second audit hit the cap with four concurrency attacks and broke nothing. Kill-tested fail-closed: freeze the gate mid-run and purchases become impossible. Clone, run scripts/verify.sh - 20/20.
AI agents can now sign up for cloud accounts, hold credentials through connector gateways, and pay for things - what is missing is the layer that decides what the agent is allowed to buy, enforced where the agent cannot negotiate with it. We put a byte-verified, conformance-tested production spending gate between an autonomous shopping agent and its money, then hired two independent adversarial audits to break the cap. The first found two real overspend paths - fixed the same day. The second attacked the fixed gate with four kinds of concurrency and could not break it. Everything is reproducible: clone the repo, run one command.
This is part of the Arc campaign series. Previous episode: operator accountability - every config change stamped with a name (EPIC-264). This article is EPIC-265: infrastructure-enforced agent budgets, built during Fly.io's Hacksgiving week.
The problem: agents got wallets before they got limits
For a junior reader, three things happened in the agent world this month, all on Fly.io - and they matter beyond one vendor:
- Agents can sign themselves up. Fly now supports
auth.md, an open spec where your coding agent registers an account with your email and gets its own short-lived credentials. No human copy-pasting API keys. - Agents can pay. A connector called Link hands the agent a single-use virtual card, capped at an amount you approved in an app.
- Agents are sandboxed. A Sprite is a hardware-isolated Linux box the agent lives in; connectors are gateway proxies that hold the actual tokens - the agent never sees them.
Notice what is missing. The cap on the Link card is per purchase you approved. The connector policy decides which services the agent may reach. But nothing answers the question a budget owner actually asks:
"What is the most this agent can spend today, no matter what it decides, no matter how it is prompted, no matter what bugs it hits?"
Not "per transaction." Not "if the model behaves." Total. Per day. Enforced by something the agent cannot talk its way around.
That is a hard question, because the agent is a language model: it is persuadable - by its own hallucinations, by prompt injection in a web page it reads, by a malformed tool response. Any limit the agent merely knows about is a limit it can be talked past. The limit has to live infrastructure-side.
What we built: the gate is not part of the agent
Our demo agent has a charming job: buy the full Thanksgiving table - turkey, gravy, cranberry, potatoes, stuffing, rolls, pie - from a demo grocery, on a budget of $100 per rolling 24 hours. Its brain is Ollama llama3.2 running inside its own Sprite. No cloud LLM: the agent is small, local, and dumb enough to be honest about what agents really do.
The full table costs $113. Watch what the architecture does with that.

The agent sprite has no path to the money that does not go through the gate. The red crosses are not firewall rules we hope hold - they are absent credentials and a provider-enforced policy.
The enforcement shape, in one breath: the agent sprite never holds the shop credential. It lives inside the Sprites connector - a gateway proxy that attaches the credential to passing requests. When the agent tried to call the connector directly, Fly's own label policy answered 403. When it tried the shop directly, 401 - it simply has no key. The only door is the mandate gate on a second sprite, and the gate is not demo code:
- It is a byte-verified snapshot of the production mmf-255 spend-enforcement module - 59 of 62 files byte-identical to the upstream repo at a pinned commit, 3 disclosed deltas (more on those below - they are the audit story).
- It passes the module's 43-vector conformance suite - inside the deployment sprite, not just in CI.
- It prices the cart itself, server-side, from its own catalog. Whatever total the agent claims is decoration.
- It reserves budget before money moves against an append-only ledger - and the ledger fails closed: corrupted file, no purchases, full stop.
The demo: three denials and a turkey
The agent's first cart is the full table - $113 against $100. The gate answers DENY DAILY_CAP_EXCEEDED, with the exact numbers. The agent replans - and being a small model, it does the most agent thing imaginable: it reshuffles the same cart and tries again. Twice.
This is the moment the video is really about. Reordering changes nothing, because nothing the agent controls is an input to the decision. The gate prices the cart from its own catalog every single time. Denied. Denied.
On round four the arithmetic lands: drop the pie, keep the turkey - $95. ALLOW. The gate reserves the budget, the connector attaches the credential the agent has never possessed, the shop settles, one receipt, one debit. The whole arc is one unedited run:
▶ Demo video (1:44) - byte-verification, the deny-replan arc, the adversarial probes, and the kill-test, narrated.

The part we are proudest of: it survived being audited
Here is where most demo posts end and where ours starts. A spending gate you wrote yourself, tested yourself, and demo yourself is a claim. We wanted evidence.
Audit one (adversarial review of the public code) came back with REQUEST CHANGES: 2 Critical, 2 High, 8 Medium - every critical with a working reproduction. The two that matter:
- Rounding mismatch. The gate and the shop rounded fractional amounts differently. An agent sending
amountUsd: 0.005two thousand times would be debited $20 against a $10 cap - the cap metered a different number than the money moved. Reproduced. - Client-declared amounts. The gate metered whatever total the agent claimed. A cart of $800 in goods "cost" $0 if the agent said so. Reproduced - with a receipt.
Both are the kind of bug that passes every happy-path test and ships. Both were fixed the same day: server-side pricing from a trusted catalog (client amounts are ignored entirely), reconcile-not-release semantics, atomic ledger writes with fail-closed reads. The fix for the ledger finding matches a bug the upstream module had already documented for its own hardening epic - our delta is disclosed in the repo's PROVENANCE.md, because honest provenance is part of the claim.
Audit two (independent cloud review) then attacked the fixed gate the way production gets attacked: with concurrency. Fifty parallel curls. Thirty same-tick promises. HTTP pipelining. Two hundred concurrent one-dollar executions against a ten-dollar cap. Final tally every time: exactly the cap, not a cent more. The reviewer independently byte-diffed our vendor tree against upstream - confirmed the provenance claim without trusting our manifest. Verdict: zero critical, zero high; the remaining medium-and-low findings (a reservation edge case on retries, a harness timeout mismatch) were fixed the same day too.
We are not aware of another agent demo whose headline is "the safety mechanism survived adversarial audit." We think it should be the baseline expectation.

The kill-test, or what "fail closed" actually means
One more frame from the video. Mid-run, we freeze the gate process - not a polite shutdown, a SIGSTOP. The agent attempts purchases.
Nothing. HTTP 000 - connection dead, no response at all. There is no fallback path, no "gate unavailable, proceeding optimistically," no silent pass. Purchases are simply impossible. Seconds later the service supervisor restarts the gate; the ledger is intact, every cent accounted for, budget accounting continuous.
If your safety mechanism has an uptime dependency, the honest question is what happens at 3 AM when it does not have uptime. Ours becomes a wall.

Honest limits - because a claim you can't falsify is marketing
- Settlement in the demo is demo-credit, an internal balance in the demo grocery. No blockchain, no card network. The point is where enforcement lives: the decision happens before money moves, on payment-rail-agnostic production code. Swap the settlement rail - crypto, card, invoice - and the gate neither knows nor cares.
- The agent's replan loop is UX, not security. Sometimes the small brain needs three rounds to drop the pie. The cap does not depend on the agent ever figuring it out - that is the entire point.
- We control the whole environment - the shop is ours, the sprites are ours. That is what makes it a demo. What makes it more than a demo is that the enforcement code is production code, byte-verified, and the audits were adversarial rather than friendly.
Verify it yourself
Everything in this article is reproducible:
git clone https://github.com/spreadzp/hacksgiving-265
cd hacksgiving-265 && bash scripts/verify.sh
One command checks the vendor tree byte-for-byte against the pinned upstream commit, runs the 43-vector conformance suite, and fires seventeen behavioral attacks at a local instance - spoofed approvals, forged intents, replay, malformed bodies, corrupt ledger. Expected output: 20/20 PASS. The adversarial probe results against the live deployment are committed at evidence/demo-results.json.
Why this matters beyond a hackathon
Agent payments are arriving as a product surface - signup specs, one-tap card approvals, connector catalogues. The platforms are competently solving "can the agent pay." The question they cannot answer for you is "should it, and how much, total, today" - because that is your policy, denominated in your risk tolerance.
That policy has to be enforced in a place the agent cannot negotiate with: server-side arithmetic, a ledger that fails closed, credentials the agent never holds, and - the part the industry skips - evidence that the mechanism survives someone actively trying to break it.
The agent in the video never learns what the cap is. It does not need to. That is what a budget is for.
The enforcement module is the production spend-gate of AgentBadge - infrastructure for agent payment accountability. The demo lives at github.com/spreadzp/hacksgiving-265.