Skip to content

Budget System Configuration Reference

Defined in lib/types/budget.ts.

ConstantValueDescription
MAX_PROJECT_BUDGET$10.00Maximum daily spend per project
MAX_DAILY_BUDGET$50.00Maximum total daily spend across all projects
FALLBACK_COST_MULTIPLIER1.5Conservative upper-bound multiplier for heuristic estimates

Defined in TIER_CONFIG in lib/types/budget.ts.

TiermaxCostminBudgetRatiorequiresHITLDescription
L0$0.100.50 (50%)NoAutonomous — no notification
L1$1.000.25 (25%)NoNotify ops, proceed
L2$5.000.10 (10%)NoSoft-gate warning
L30YesHITL approval required

Tier assignment: A request is assigned the highest L tier where BOTH maxCost < tier.maxCost AND minBudgetRatio ≤ budgetRatio are satisfied. The tighter of projectBudgetRatio and dailyBudgetRatio is used.


Defined in MODEL_RATES in lib/types/budget.ts.

ModelInput (per token)Output (per token)
claude-opus-4-6$0.000015$0.000075
claude-sonnet-4-6$0.000003$0.000015
claude-haiku-4-5$0.00000025$0.00000125
gpt-4o$0.0000025$0.00001
gpt-4o-mini$0.00000015$0.0000006
default$0.000003$0.000015

CircuitBreaker accepts a CircuitBreakerConfig in its constructor.

PropertyDefaultDescription
failureThreshold3Consecutive failures to open the circuit
recoveryWindowMs300_000 (5 min)Time in OPEN before trying HALF_OPEN
successThreshold1Successes in HALF_OPEN to close circuit

DiscordAlerter accepts a DiscordAlertConfig partial.

PropertyDefaultEnvironment VariableDescription
webhookUrl""DISCORD_BUDGET_WEBHOOK_URLPrimary alert webhook
opsWebhookUrl""DISCORD_OPS_WEBHOOK_URLFallback ops webhook
thresholds[0.5, 0.8]Budget usage fractions to alert at
maxRetries7Max webhook delivery retries
initialBackoffMs1000Initial exponential backoff delay

The default HITL escalation timeout is 30 minutes (1800 seconds). Requests that expire without a decision are auto-rejected per deviation rules.

This is hardcoded in lib/plugins/budget.ts:

expiresAt: new Date(Date.now() + 30 * 60 * 1000).toISOString()

MetricTargetAlert Threshold
autonomous_rate85–90%< 85% triggers ops alert

TopicPayload TypeDescription
budget.request.{suffix}BudgetRequestTrigger pre-flight cost check
budget.actual.{suffix}BudgetActualReport actual post-execution cost
budget.decision.{requestId}BudgetDecisionCost check result
hitl.request.budget.{requestId}HITLRequest (with cost fields)L3 escalation
ops.alert.budget{ type, ... }Budget system ops alerts
budget.circuit.open.{key}{ type, key, circuitState }Circuit breaker opened