Skip to content
SlashClone

Consumption guardrails

@agentcosts/consumption-guardrails

Set and check consumption guardrails for an AI product: per-customer daily and monthly spend caps, month-end forecasts, spend spike rules, runaway agent runs, and failure rate spikes, plus a runbook for what to do when each alert fires. Runs on usage files; exit code 2 on critical alerts for cron or CI.

SkillDevOpsv1.0.0 (latest)Tested
Activity
New: be the first to try it
  1. 1# Consumption guardrails
  2. 2
  3. 3Sets spend caps, forecasts, spike rules, and runaway-run limits for each customer of your AI product, checks your usage against them, and writes a runbook for what to do when each alert fires. Exit code 2 on critical alerts, so it drops into a cron job or CI step.
  4. 4
  5. 5**Who it is for:** founders and engineers running agent products who have been surprised by a bill, or want to make sure they never are.
  6. 6
  7. 7## Example
  8. 8
  9. 9Input: `examples/usage.csv` (October usage, including a day when one customer's research agent looped), `examples/guardrails.json`.
  10. 11```
  11. 12node scripts/guardrails.mjs examples/usage.csv --config examples/guardrails.json --prices examples/prices.csv --as-of 2026-10-27
  12. 13```
  13. 15Output (`out/guardrails.md`):
  14. 17| Severity | Customer | Rule | Detail |
  15. 18| --- | --- | --- | --- |
  16. 19| CRITICAL | cobalt-labs | daily cap | Spent $23.39 on 2026-10-27, cap $4.00. |
  17. 20| CRITICAL | cobalt-labs | spend spike | 13.6x the 7-day median of $1.71. |
  18. 21| CRITICAL | cobalt-labs | runaway runs | 6 research_agent runs over $3.00 per run or 25 calls per run (up to 52 calls). |
  19. 22| WARNING | cobalt-labs | monthly forecast | On pace for $66.24 this month, over the $60.00 cap. |
  20. 23| WARNING | cobalt-labs | failure rate | 6 of 6 research_agent runs failed. |
  21. 25Plus `out/guardrails-runbook.md`, written with you from `templates/runbook.md`.
  22. 27## What it can access
  23. 29- Runs `node scripts/guardrails.mjs` (Node built-ins only).
  24. 30- Reads `data/`. Writes `data/guardrails.json` (your limits) and `out/guardrails*`.
  25. 31- No network. It reports; it never blocks or throttles anything.
  26. 33## Setup
  27. 35None to try it. To run it daily, schedule the command after your usage export. Check the example LLM prices against each provider's current pricing first.