---
title: "Bound how far a cap can be overshot · Agent Wranglers"
url: https://agentwranglers.se/playbook/pricing/spend-caps-and-alerts/cap-overshoot
id: PRC-11
level: Recommended
applies: payments
updated: 2026-10-27
build: a2a6bdfed830
tokens: 904
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Bound how far a cap can be overshot

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Spend caps and alerts](https://agentwranglers.se/playbook/pricing/spend-caps-and-alerts.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: PRC-11
- Level: Recommended
- Chapter: [Spend caps and alerts](https://agentwranglers.se/playbook/pricing/spend-caps-and-alerts.md)
- Rule: Write the largest overshoot each spend cap allows, such as 1% of the cap. Enforce it with holds or a strongly consistent counter on the request path, never with a total that lags.
- Check: A load test sends 1,000 parallel requests from one account with a cap worth 100 of them. At most the written overshoot above 100 succeeds, and the rest get the cap error.
- Applies when: The project takes payments.
- How: Usage totals often come from a pipeline that lags by minutes. A customer, or a runaway agent, can send thousands of requests before the total reaches the cap. Take a hold for each request in the same store that checks the cap, as [Hold credits before costly work and settle after](https://agentwranglers.se/playbook/usage-billing/credits-and-prepaid-balances/credit-holds.md) does. Several servers then cannot all pass the check at once. When the cap store is spread over regions, give each region a share of the remaining cap. Requests in flight when the cap is reached may finish, and they are the overshoot you wrote down. Refuse new ones as [Let customers cap their spend](https://agentwranglers.se/playbook/pricing/spend-caps-and-alerts/customer-spend-cap.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
export async function reserveUnderCap(db, accountId, costMinor) {
  const reserved = await db.query(
    `UPDATE spend_caps SET held_minor = held_minor + $2
     WHERE account_id = $1 AND spent_minor + held_minor + $2 <= cap_minor
     RETURNING account_id`, [accountId, costMinor])
  return reserved.rowCount === 1
}
```

### Python example

```python
def reserve_under_cap(db, account_id, cost_minor) -> bool:
    reserved = db.execute(
        """UPDATE spend_caps SET held_minor = held_minor + %s
           WHERE account_id = %s AND spent_minor + held_minor + %s <= cap_minor
           RETURNING account_id""", (cost_minor, account_id, cost_minor))
    return reserved.rowcount == 1
```

## Related rules

- USG-7 [Hold credits before costly work and settle after](https://agentwranglers.se/playbook/usage-billing/credits-and-prepaid-balances/credit-holds.md) in Usage-based billing
- PRC-7 [Let customers cap their spend](https://agentwranglers.se/playbook/pricing/spend-caps-and-alerts/customer-spend-cap.md) in Pricing, plans and entitlements

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/pricing/spend-caps-and-alerts/cap-overshoot">Agent Wranglers pricing, plans and entitlements playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Let owners set a cap on each member and key](https://agentwranglers.se/playbook/pricing/spend-caps-and-alerts/scoped-spend-caps.md)
- [Spend caps and alerts](https://agentwranglers.se/playbook/pricing/spend-caps-and-alerts.md)
