runaway-cost-guardrails

Enforces iteration, token, time, and action caps on agent loops to stop runaway spend.

1|Updated Jul 3, 2026
One-click install
npx skills add https://github.com/Nandansai08/skillz --skill runaway-cost-guardrails-nandansai08
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: runaway-cost-guardrails
Source: https://github.com/Nandansai08/skillz/tree/main/skills/loop-engineering/runaway-cost-guardrails
Command: npx skills add https://github.com/Nandansai08/skillz --skill runaway-cost-guardrails-nandansai08

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Agent loops can hit inputs their stop conditions never anticipated, spinning for thousands of iterations and generating massive bills before anyone notices. This Skill provides the layered enforcement — iteration caps, token and spend budgets, wall-clock limits, and kill switches — that bounds the damage when a loop's own stopping strategy fails. ## Core Features & Use Cases - Four-axis capping: Set independent limits on iterations, tokens/spend, wall-clock time, and expensive action classes (external API calls, message sends), with values derived from measured p95 distributions per task class. - Layered enforcement: Combine in-loop budget awareness, harness-level hard stops, platform-level API key spend caps, and billing alerts so no single failure point leaves the loop unbounded. - Graceful budget exits: Persist state, emit exit-labeled traces, and produce handoff reports when caps fire, so partial work survives and cap events don't become total losses. - Use Case: After an overnight agent run burns $3,400 on an unresolvable git edge case, use this Skill to rebuild with per-run caps, per-key daily spend limits, fleet spend-rate alarms, and a staging drill that verifies each layer fires in order. ## Quick Start Set hard iteration, spend, and time caps on my agent loop based on its measured p95 run distribution, with a harness-level kill switch and a budget-exit handoff report.

Frequently Asked Questions about runaway-cost-guardrails

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I stop an AI agent loop from running up huge API costs?▼

Cap all four axes independently: iterations, tokens/spend, wall-clock time, and expensive action classes like external API calls. Set values at roughly p95 of legitimate runs times 2-3 margin per task class, and enforce them with a harness-level hard stop plus platform-level API key spend caps.

How to set token budget limits for LLM agents?▼

Derive budgets from measured cost distributions of real or pilot runs, not guesses — caps set at p50 throttle half your normal workload, while caps at p95 times 2-3 catch only the pathological tail. Use different budgets per task class since a triage task and a migration task have different legitimate costs.

Is a prompt instruction enough to limit agent iterations?▼

No — a prompt instruction is only a cooperative layer, and it fails precisely in the runaway case where the agent's judgment has already degraded. You need a mechanical harness-level hard stop and platform-level API key caps that survive harness bugs.

Why did my agent run all night despite a billing alert?▼

Billing alerts fire in hours-to-days granularity, after the money is already spent — they are the last-resort layer, not the guardrail. The runaway happened because harness-level hard stops and platform spend caps were absent, so nothing bounded the loop mechanically.

When should I not use budget caps as the stopping mechanism?▼

Budget caps are backstops, not the normal exit strategy — a loop that routinely exits on budget is misconfigured upstream. Use convergence-criteria-design to make loops stop at good-enough naturally, and treat caps as enforcement for when that fails.

What should happen when an agent hits its budget cap?▼

The budget exit should be a first-class outcome: persist state and partial results, emit an exit-labeled trace, and produce a handoff report describing what was attempted and why it likely didn't converge. Route by task type to park-for-human, a single bigger-budget retry, or a visible failure — never recursive auto-retries.