| name | cost-optimizer |
| license | Apache-2.0 |
| description | Tracks cumulative LLM costs across DAG execution and makes real-time decisions to stay within budget. Downgrades models, skips optional nodes, or stops early when cost exceeds thresholds. Use when managing execution budgets, analyzing cost breakdowns, or optimizing model routing for cost. Activate on "cost budget", "too expensive", "reduce cost", "cost optimization", "model downgrade", "budget exceeded". NOT for LLM model selection logic (use llm-router), pricing comparisons across providers, or billing/invoicing. |
| allowed-tools | Read,Grep |
| argument-hint | [dag-id] [budget-usd] |
| metadata | {"tags":["cost","optimizer","cost-budget","too-expensive","reduce-cost"],"pairs-with":[{"skill":"cost-accrual-tracker","reason":"The tracker provides the real-time cost data that the optimizer uses for budget decisions"},{"skill":"llm-router","reason":"Model routing is the primary mechanism through which cost optimization is enacted"},{"skill":"cost-verification-auditor","reason":"Post-execution auditing validates that optimization decisions actually reduced costs"}]} |
| category | Content & Marketing |
| tags | ["cost-optimization","pricing","monetization","unit-economics","strategy"] |
Cost Optimizer
Tracks cumulative LLM costs across DAG execution and makes real-time decisions to stay within budget: downgrade models, skip optional nodes, or stop early.
When to Use
✅ Use for:
- Setting and enforcing cost budgets for DAG executions
- Real-time cost monitoring during execution
- Deciding when to downgrade model tiers mid-execution
- Identifying which nodes are most expensive and why
- Post-execution cost analysis and optimization recommendations
❌ NOT for:
- Choosing which model to use per node (use
llm-router)
- Provider pricing comparisons (static data, not a skill)
- Billing or invoicing features
Budget Enforcement Process
flowchart TD
N[Node about to execute] --> C[Check: spent + estimated_node_cost vs budget]
C --> S{Within budget?}
S -->|Yes, >20% remaining| E[Execute at planned model tier]
S -->|Yes, <20% remaining| W[Execute but downgrade to Tier 1 if possible]
S -->|No| D{Node optional?}
D -->|Yes| SK[Skip node]
D -->|No| H{Human gate available?}
H -->|Yes| A[Ask human: continue over budget?]
H -->|No| ST[Stop execution, return partial results]
Budget Tiers
| Budget Remaining | Action |
|---|
| >50% | Execute at planned model tier |
| 20-50% | Log warning. Continue at planned tier. |
| 10-20% | Downgrade remaining Tier 2 nodes to Tier 1 (Haiku) |
| 5-10% | Downgrade ALL remaining nodes to Tier 1. Skip optional nodes. |
| <5% | Stop execution unless next node is critical path |
| 0% | Stop. Return partial results with cost breakdown. |
Cost Estimation Per Node
Before each node executes, estimate its cost:
estimated_cost = (avg_input_tokens × input_price + avg_output_tokens × output_price)
Use historical averages for this skill + model combination. If no history, use defaults:
- Tier 1 (Haiku): ~800 input + 400 output = ~$0.001
- Tier 2 (Sonnet): ~2000 input + 1000 output = ~$0.012
- Tier 3 (Opus): ~3000 input + 1500 output = ~$0.16
Post-Execution Report
{ , }
{ , }
{ , }