runaway-guard
Was er macht
Diese Anleitung hilft dir, unerwartete Kosten bei der Nutzung bezahlter KI-Dienste zu vermeiden. Du legst Ausgabenlimits fest, bevor du Code ausführst, der diese APIs aufruft.
Wann du ihn nutzt
- ✓Wenn du KI-APIs nutzt, die nach Verbrauch abgerechnet werden.
- ✓Wenn du Code schreibst oder prüfst, der viele Aufrufe an diese APIs macht.
- ✓Um böse Überraschungen auf der Rechnung am Monatsende zu vermeiden.
Link zum Skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/runaway-guard/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Wie kann ich sicherstellen, dass ich nicht zu viel Geld für die OpenAI API ausgebe?”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Du legst klare Grenzen fest, wie viel du pro Aufruf, pro Tag und pro Ausführung ausgeben darfst. Diese Limits setzt du sowohl in deinem Code als auch auf der Plattform des KI-Anbieters.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
runaway-guard — $-Cost is the Third Complexity Dimension
Every loop has time complexity and space complexity. A loop that calls a paid API has a third: dollars per execution. The model tracks the first two automatically. It does not track the third, so it ships code where a single bug — a retry without bound, a stream reconnect storm, an agent that re-queues itself, a webhook that fires the same job twice — silently spends real money.
The canonical incident: developer writes a Fal.ai image-generation loop. Loop "obviously terminates" because it iterates over a fixed list. The list comes from a callback that fires on every Inngest retry. Each retry doubles the list. By morning, the bill is $200. Tests pass. Code review passed. The bug is not in the loop body. The bug is that no one stated the wallet invariant.
runaway-guard fixes this. State the max calls. State the max dollars per run. State the max dollars per day. Set the same caps in the provider dashboard so a code bug cannot bypass them. Then write the code.
Violating the letter of these rules is violating the spirit of the skill. "I'm only testing locally" is the exact rationalization that ships the $200 bill — local code hits the same paid API as production.
When to Use This Skill
Use runaway-guard when:
- Writing or reviewing code that calls a paid AI / inference API in a loop, queue, retry path, agent step, webhook handler, or background job.
- Importing or wrapping any paid-inference SDK:
@fal-ai/*,fal-client,@anthropic-ai/sdk,anthropic,openai,replicate,elevenlabs,together-ai,groq-sdk,cohere-ai,@mistralai/*. - Designing an agent loop, fan-out pipeline, retry wrapper, polling job, stream reconnect, or self-rescheduling job that may call a billed endpoint.
- Auditing a codebase / PR for unbounded fan-out, unbounded retries, missing idempotency keys, or missing provider-side spend caps.
- Diagnosing an unexpected bill, runaway loop incident, or surprise overage.
The Iron Law
NO CALL TO A PAID API WITHOUT A WRITTEN $-CAP AT BOTH THE CODE AND PROVIDER LEVEL
A cap only in code can be bypassed by a bug in that code. A cap only at the provider can be hit during normal usage and degrade the product. You need both. If you cannot state both in one sentence each, you have not designed the call site — you have written a wish.
Non-negotiable rules
Every call site gets a one-line cost contract. Before writing any paid-API call, state in one sentence:
- Max calls per run: the strict upper bound on invocations in a single execution of this code path.
- Max $ per run:
max_calls × unit_cost— compute it, don't estimate. - Max $ per day: the provider-side hard cap that backstops the code-side bound.
Examples:
- "Fal flux-pro at $0.05/image; max 20 images per job; max $1 per job; provider Spend Limit $50/day."
- "Anthropic Sonnet at ~$0.015 per request (cached); max 50 requests per agent run; max $0.75 per run; Workspace Budget hard cap $30/day."
If you cannot fill in all three numbers, you have not designed the call site.
Every loop calling a paid API gets an explicit iteration bound, not just a termination argument.
invariant-guardrequires a termination measure. runaway-guard requires the bound to be a concrete integer in code, not just "eventually terminates":// ❌ Terminates in theory. Bills $200 in practice. while (job.status !== 'done') { await fal.run(...); } // ✅ Concrete bound — wallet invariant explicit. const MAX_CALLS = 20; for (let i = 0; i < MAX_CALLS && job.status !== 'done'; i++) { await fal.run(...); } if (job.status !== 'done') throw new Error('exceeded MAX_CALLS budget');Every retry path is bounded by attempts AND total elapsed cost, not by time alone. Exponential backoff with no attempt cap is a wallet attack on yourself.
- Max attempts: a small integer (3–5 for transient errors, 1 for 4xx).
- Cap counts across the whole pipeline, not just one library — Inngest retries × SDK retries × your own retry wrapper multiply.
- 4xx errors do not retry. Period. They will not become 2xx; they will just bill again.
Every fan-out path declares a concurrency limit. Parallel calls multiply cost per wall-clock second. State the limit in code, at the queue (Inngest
concurrency), and at the provider where supported:
…
Häufige Fragen
Warum brauche ich Limits?
Bezahlte KI-APIs können schnell teuer werden, wenn im Code ein Fehler steckt, zum Beispiel eine Schleife, die nie endet. Limits verhindern, dass aus einem kleinen Fehler eine große Rechnung wird.
Was sind 'Kosten pro Ausführung'?
Das ist die maximale Summe, die in einem einzelnen Durchlauf deines Codes ausgegeben werden darf. Wenn du zum Beispiel ein Limit von 10 Aufrufen hast und jeder Aufruf $0.01 kostet, liegen die Kosten pro Ausführung bei $0.10.
Warum muss ich das Limit sowohl im Code ALS AUCH auf der Plattform des Anbieters setzen?
Im Code ist das die erste Verteidigungslinie. Auf der Plattform des Anbieters stellst du sicher, dass die Ausgaben auch von außen gestoppt werden, selbst wenn der Code versagt. Das ist wie ein Sicherheitsnetz.
Details
Originalbeschreibung des Autors
Cost-safety discipline for paid AI / inference APIs: treat $-cost as a third complexity dimension alongside time and space. Forces a written per-run $-cap, per-day $-cap, max-iterations bound, concurrency limit, and a matching provider-dashboard hard cap BEFORE any call site is written.
Beliebtheit
- GitHub-Sterne
- 48k
- Platz im Ranking
- #5651
- Lizenz
- MIT
- Aktualisiert
- 15.10.2026
Kommentare
- …
Weitere Skills aus diesem Repository
00-andruia-consultant
48kHilft deinem Agenten, KI-Projekte zu starten oder zu verbessern. Er analysiert Code, schlägt Tools vor und erstellt Aktionspläne auf Spanisch.
007
48kLässt deinen Agenten Sicherheitsaudits und Bedrohungsmodellierung durchführen. Nützlich, um Projekte vor Angriffen und Schwachstellen zu schützen.
10-andruia-skill-smith
48kHilft deinem Agenten, KI-Tools zu erstellen oder zu verbessern. Er legt fest, wie Tools funktionieren, schreibt die Dokumentation und prüft die Struktur.
20-andruia-niche-intelligence
48kLässt deinen Agenten eine Branchenzusammenfassung erstellen. Nützlich, um Kontext, Regeln, Nutzungsmuster und Risiken anhand verlässlicher Quellen zu verstehen.
Ähnliche Skills
knowledge-automation
394kHilft deinem Agenten, einen wiederkehrenden Auftrag einzurichten, der regelmäßig neue Inhalte in deinen Knowledge-Vault bringt, und danach zu prüfen, ob er läuft.
knowledge-source-ingest
394kHilft deinem Agenten, den Knowledge-Vault mit neuen Einträgen aus Chat-Kanälen, Feeds oder Postfächern aktuell zu halten, ohne bereits Vorhandenes erneut hinzuzufügen.
benchmark
280kHilft deinem Agenten, die Geschwindigkeit und Performance von Code zu messen. Nützlich, um Tempo sicherzustellen und Bremsen zu finden.