executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
plan-llm-cost-guardrailsPlan-only audit of an LLM app's runaway-cost and quota-abuse exposure. Use when "cap my AI costs", "my LLM bill could blow up", "rate limit my AI", "token budget", "runaway agent loop", or hardening LLM features before launch.
Independent GitHub snapshot · Automated classification · Original documentation governs
Degree of freedom: HIGH — inventory call sites, score unbounded paths, plan. Stay plan-only. No limits or routing changes until approved.
| Skill | Owns |
|---|---|
| plan-llm-cost-guardrails (this) | Token / quota / runaway-loop plan |
audit-langfuse-llm | Quality and cost traces |
audit-infra-cost | Hosting / egress bill |
audit-llm-security | Unbounded consumption as an attack |
Propose: per-user daily token cap + hard daily-spend kill switch on
lib/ai.ts. Risk: public/api/chatcan replay a 50K context until the bill dies; RPM-only does not count. Keep-working: summarizer path already setsmax_tokens. Phase: Phase 1 — caps & kill switch.
Role: Senior platform engineer (LLM spend + abuse resistance).
Task: Inventory every LLM call site, test against the 3-layer guardrail model,
score unbounded paths, phase remediations, emit plan-llm-cost-guardrails.md.
Audit & plan only — no limits or routing changes until approved.
Find every path to a runaway bill. Cap it. Change nothing until approved.
Token cost scales with input + output tokens, not request count — a single 50K-token context replayed three times can exhaust a budget while staying under any RPM cap. Vibe-coded AI features ship with no spend cap, no per-user quota, no output-token cap, no circuit breaker — compounded by prompt-injection cost amplification and forged-webhook quota fraud (the empty-signing-secret bypass class).
This is the prevention counterpart to Langfuse observability: Langfuse tells you what spend happened; this audits what's capped.
Trigger phrases: "cap my AI costs", "my LLM bill could explode", "rate limit my AI", "token budget", "someone could drain my quota", "runaway agent loop", "per-user AI limits", "pre-launch cost hardening".
Do not fire for: output quality/evals (audit-langfuse-llm), generic API
performance, or trace visibility (plan-error-handling). This owns bounded spend.
max_tokens (Anthropic),
max_completion_tokens or max_output_tokens (OpenAI); bound worst-case
cost; truncate RAG context.stream_options.include_usage; Anthropic sends it in message_start and
cumulative message_delta events.plan-input-validation.plan-llm-cost-guardrails.md, then end the turn with a standalone recap in chat: the two or three highest-impact findings and the first phase to approve. The file is the deliverable — write it before the recap.plan-input-validation.audit-langfuse-llm; unauth AI input → plan-input-validationplan-llm-cost-guardrails.md# LLM Cost-Guardrail Audit — <repo>
_Audit-only. No limits or routing change until each phase is approved._
## Scope
- LLM call sites: n | Public AI endpoints: n | Langfuse present: ☐
## Verdict
| Layer | Present? | Worst gap |
|-------|----------|-----------|
| 1 Limits (token-aware) | partial | unbounded max_tokens |
| 2 Circuit breakers | ❌ | no daily kill switch |
| 3 Fallback chain | ❌ | limit = hard error |
## Findings
| # | Call site | Unbounded path | Worst-case | Missing layer | Sev | Direction |
|---|-----------|----------------|------------|---------------|-----|-----------|
## Phased burndown
- **Phase 1 — Caps & kill switch** → `backend-patterns`
- **Phase 2 — Circuit breakers** → `backend-patterns`
- **Phase 3 — Fallback chain** → `backend-patterns`
- **Phase 4 — Visibility** → `audit-langfuse-llm` / `backend-observability`
- **Cross-hand** → `plan-input-validation`
## Execution handoff
Simulate a runaway in test env after Phase 1; confirm cap holds before bill moves.
plan-error-handling (visibility) and
audit-langfuse-llm (quality); this owns bounded spend.audit-llm-security — LLM10 unbounded consumption is the attack-shaped twin.audit-infra-cost — hosting/egress, not tokens.backend-patterns, audit-langfuse-llm, backend-observability.Plan at high effort. Execute after approval at the default effort under
approved-plan-execution.mdc(no reward hacking, no feature deletion).