Show current LLM usage budget and spending across all diagnosis runs
Quick-reference skill for viewing LLM diagnosis spending in the rounds error diagnosis system.
/rounds-budget
Display current budget consumption and spending statistics for LLM-powered error diagnosis across the rounds system. This skill helps monitor:
DAILY_BUDGET_LIMIT (default: $100.00 USD)signatures.dbrounds/config.py:
claude_code_budget_usd (default: $2.00 per diagnosis)openai_budget_usd (default: $2.00 per diagnosis)daily_budget_limit (default: $100.00)The daemon scheduler (rounds/adapters/scheduler/daemon.py:209-231) tracks daily spending in-memory and enforces limits during poll cycles.
Read budget settings from environment or defaults:
# View current budget configuration
grep -E "budget|BUDGET" .env 2>/dev/null || echo "Using defaults from config.py"
# View configuration schema
grep -A 5 "Budget controls" rounds/config.py
The SQLite database stores all diagnosis costs in the diagnosis_json field of the signatures table. Extract and sum costs:
# Connect to SQLite and query diagnosis costs
sqlite3 ./data/signatures.db "
SELECT
COUNT(*) as total_diagnoses,
SUM(json_extract(diagnosis_json, '$.cost_usd')) as total_spent_usd,
AVG(json_extract(diagnosis_json, '$.cost_usd')) as avg_cost_per_diagnosis,
MAX(json_extract(diagnosis_json, '$.cost_usd')) as max_single_diagnosis,
MIN(json_extract(diagnosis_json, '$.cost_usd')) as min_single_diagnosis
FROM signatures
WHERE diagnosis_json IS NOT NULL;
"
Break down diagnosis costs by service to identify high-cost areas:
sqlite3 ./data/signatures.db "
SELECT
service,
COUNT(*) as diagnoses_count,
SUM(json_extract(diagnosis_json, '$.cost_usd')) as service_total_usd,
AVG(json_extract(diagnosis_json, '$.cost_usd')) as avg_cost_usd
FROM signatures
WHERE diagnosis_json IS NOT NULL
GROUP BY service
ORDER BY service_total_usd DESC;
"
Show the most recent diagnosed errors and their costs:
sqlite3 ./data/signatures.db "
SELECT
substr(id, 1, 8) as sig_id,
service,
error_type,
json_extract(diagnosis_json, '$.model') as model,
json_extract(diagnosis_json, '$.cost_usd') as cost_usd,
json_extract(diagnosis_json, '$.confidence') as confidence,
datetime(json_extract(diagnosis_json, '$.diagnosed_at')) as diagnosed_at
FROM signatures
WHERE diagnosis_json IS NOT NULL
ORDER BY json_extract(diagnosis_json, '$.diagnosed_at') DESC
LIMIT 10;
"
The daemon scheduler tracks daily spending in-memory (_daily_cost_usd in rounds/adapters/scheduler/daemon.py:38-40). This resets at midnight UTC. To view current daily spending while daemon is running, you would need to:
_daily_cost_usd valuesqlite3 ./data/signatures.db "
SELECT
COUNT(*) as today_diagnoses,
SUM(json_extract(diagnosis_json, '$.cost_usd')) as today_spending_usd
FROM signatures
WHERE diagnosis_json IS NOT NULL
AND date(json_extract(diagnosis_json, '$.diagnosed_at')) = date('now');
"
The daemon (rounds/adapters/scheduler/daemon.py:187-207) checks budget limits before each investigation cycle:
daily_budget_limit is set (e.g., DAILY_BUDGET_LIMIT=100.0), spending is tracked_daily_cost_usd >= budget_limit, investigation cycles are skippedTo verify budget enforcement:
# Check if daemon would skip investigations
# (requires reading daemon logs or adding status endpoint)
grep -E "budget.*exceeded|Daily budget limit" logs/rounds-daemon.log 2>/dev/null || echo "No budget warnings found"
/rounds-budget
# Output shows:
# - Total diagnoses: 42
# - Total spent: $84.50 USD
# - Avg cost: $2.01 USD
# - Budget limit: $100.00 USD
# - Remaining today: $15.50 USD
After running the skill, you'll see:
Service Spending Report:
------------------------
payment-api: $32.40 (16 diagnoses, avg $2.03)
user-service: $28.14 (14 diagnoses, avg $2.01)
notification-svc: $24.00 (12 diagnoses, avg $2.00)
Total: $84.54 across 42 diagnoses
Daily Limit: $100.00 (15.46% remaining)
/rounds-budget
# If daily spending exceeds limit:
# ⚠️ BUDGET EXCEEDED: $103.50 / $100.00 (103.5%)
# Investigation cycles are currently paused.
# After running /rounds-budget, follow up with date-based query:
sqlite3 ./data/signatures.db "
SELECT
date(json_extract(diagnosis_json, '$.diagnosed_at')) as diagnosis_date,
COUNT(*) as count,
SUM(json_extract(diagnosis_json, '$.cost_usd')) as daily_total_usd
FROM signatures
WHERE diagnosis_json IS NOT NULL
GROUP BY diagnosis_date
ORDER BY diagnosis_date DESC
LIMIT 7;
"
# Shows spending trends over the last 7 days
rounds/config.py:82-101 - Budget configuration (per-diagnosis and daily limits)rounds/adapters/scheduler/daemon.py:209-231 - Daily budget tracking and enforcementrounds/core/investigator.py:18-22 - BudgetTracker protocol interfacerounds/adapters/store/sqlite.py:97,425,440 - Diagnosis cost storage in diagnosis_jsonrounds/core/models.py:107 - Diagnosis.cost_usd field./data/signatures.db - SQLite database storing all diagnosis costsBudget tracking in rounds follows the hexagonal architecture pattern:
rounds/core/investigator.py:18-22) defines the BudgetTracker protocolrounds/adapters/scheduler/daemon.py) implements budget enforcementrounds/adapters/store/sqlite.py) stores historical costs in JSONrounds/config.py) provides budget limits from environmentThe daemon scheduler serves dual purposes:
BudgetTracker protocol)This skill was automatically generated from the rounds codebase architecture.