Blog · Developers

A rolling 24-hour spend cap for AI agents, explained.

A monthly budget tells you what happened. A spend cap decides what is allowed to happen next. For software that spends money on its own, the shape of that cap matters more than its size.

By the Nexus402 team 5 min read

The short answer

A rolling 24-hour spend cap limits what a key may spend in any 24 hours counted back from now. Unlike a daily or monthly budget, it has no reset moment to exploit or to be surprised by: each call is allowed only if the spend of the last 24 hours plus its price fits under the cap. On Nexus402, a call that would pass it is refused with 402 and nothing is charged.

The trouble with resets

Calendar budgets reset at a moment: midnight, or the first of the month. That moment is the weak point. An agent that spends its whole daily budget at 23:50 can spend another whole budget at 00:10, twice the limit inside twenty minutes. A monthly budget is worse: by the time it is reached, a loop may have been running for days.

People cope with resets because they notice what they spend. An agent does not. It needs a limit that holds the same way at every moment.

How a rolling window works

A rolling window has no reset. At every call it asks one question: would this call push the spend of the last 24 hours over the cap? If yes, the call is refused. Spend older than 24 hours drops out of the count on its own, so room comes back gradually, in the same rhythm it was used.

The result is a guarantee you can state in one sentence: in no 24-hour period, starting at any minute, can this key spend more than its cap.

A worked example

cap = $5.00 per rolling 24 hours

09:00  spend $4.80   allowed, $0.20 of headroom left
09:01  spend $0.50   refused with 402, nothing charged
next day 09:01       the 09:00 spend ages out, headroom returns

At 09:01 the key has spent $4.80 in the last 24 hours, and a $0.50 call would take it to $5.30, so it is refused before anything is taken. The next morning, the 09:00 spend is more than 24 hours old, no longer counts, and calls flow again.

Choosing the number

  • Start from a normal day. Look at what the agent spends on a typical day and set the cap a little above it, so ordinary work never hits it and a loop does quickly.
  • One cap per agent. Separate keys mean a runaway agent spends its own budget, not another's.
  • Pair it with an allowlist and a price limit, so an agent choosing tools on its own cannot pick an expensive one you did not intend.
  • Revisit it when the agent's job changes. A cap can be raised or lowered at any time.

On Nexus402

Every key is created capped or uncapped, and you say which: a positive cap in micro-dollars, or "uncapped": true. Sending neither, or a cap of "0", is refused rather than quietly read as unlimited. The cap can be changed later through the key's policy, and no heuristic, abuse detector or operator lowers a cap you set.

Underneath every key sits the wallet, which you fund in advance with no automatic top-up and no card on file to draw on. So even an uncapped key cannot spend more than you have already put in. Free calls from creators do not count against the cap at all. The budget guide puts the cap together with the other controls.

Questions

Asked often.

Frequently asked questions

What is a rolling 24-hour spend cap?

A limit on how much a key may spend in any 24-hour period, measured back from now rather than from midnight. Spend older than 24 hours stops counting, so room returns gradually instead of all at once.

What happens when an agent hits the cap?

The next call that would pass it is refused with 402 Budget_Exhausted and nothing is charged. As earlier spend ages past 24 hours, calls are allowed again.

Does every key need a cap?

No. You choose when you create a key: a positive cap, or uncapped. An uncapped key is bounded only by the wallet balance, which is always funded in advance.

Do free calls count against the cap?

No. A creator's free calls debit nothing and do not count against a key's 24-hour cap.

Set a cap your agent cannot talk past.

One key per agent, a rolling 24-hour ceiling on each, and a wallet you fund yourself.