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 runbook: <product name>
  2. 2
  3. 3Owner: <role>. Review these limits every quarter and after any pricing change.
  4. 4
  5. 5## Limits
  6. 6
  7. 7| Limit | Default | Exceptions | Why this number |
  8. 8| --- | --- | --- | --- |
  9. 9| Daily spend per customer | $<x> | <customer: $y> | about 3x a normal heavy day |
  10. 10| Monthly spend per customer | $<x> | <customer: $y> | keeps gross margin above <target>% at their price |
  11. 11| Cost per run | $<x> | | 3x the p95 cost of the most expensive task |
  12. 12| Calls per run | <n> | | stops agent loops |
  13. 13| Spend spike | <m>x the 7-day median, at least $<min> | | |
  14. 14| Failure rate | over <x>% with at least <n> runs in a day | | |
  15. 16## When an alert fires
  16. 18| Alert | First 15 minutes | Same day | Who decides |
  17. 19| --- | --- | --- | --- |
  18. 20| Runaway runs (critical) | Find the run IDs in the alert, check for a loop or retry storm, stop the job or feature flag the task for that customer | Fix the cause, add a test, refund if the customer was billed for failures | Engineering on call |
  19. 21| Spend spike (critical) | Check if it is real use (a launch, a batch import) or a bug; message the account owner | If real, check the customer's cap and plan; if a bug, treat as runaway | Engineering on call + account owner |
  20. 22| Daily cap (critical) | Apply the agreed action: <throttle / queue / pause non-urgent tasks / notify only> | Talk to the customer about plan or overage | Account owner |
  21. 23| Monthly forecast (warning) | Nothing urgent | Account owner contacts customer before the cap is hit; offer a plan change | Account owner |
  22. 24| Failure rate (warning) | Check provider status and recent deploys | Fix or roll back; failed runs still cost money | Engineering |
  23. 26## What we never do automatically
  24. 28- Cut off a paying customer without a human decision.
  25. 29- Raise a cap without the account owner and finance agreeing.
  26. 31## How it runs
  27. 33- `node scripts/guardrails.mjs data/usage.csv --config data/guardrails.json --fail-on-alert` on a schedule (<daily at 9:00 / hourly>), after usage is exported.
  28. 34- Exit code 2 means at least one critical alert. <Where alerts go: a channel, an email, an on-call tool>.