Spend Caps & Emergency Kill Switch
Stops runaway token spend before calls happen and gives operators a 1-click emergency stop.
A buggy loop or 10 parallel agents burn $500 overnight before anyone notices on the billing dashboard.
Agents stop the instant they reach their budget cap — or immediately when you flip the kill switch.
What It Does (In Plain English)
Budget enforces hard limits on dollars (maxCostUsd), tokens, steps, and actions per task, goal, or scope. It reserves estimated spend *before* parallel agents call an LLM so concurrent runs cannot race past your cap, and provides an instant tenant-wide kill switch.
Real-World Example
- 1Operator sets a $5.00 budget on Goal #12.
- 2Three sub-agents run in parallel; each reserves its step estimate from the shared $5.00 pool.
- 3If an upstream outage happens, operator runs
neusym kill-switch on— all writes and LLM calls halt immediately.
When Should You Turn It On?
Required automatically at Level 1 (review) and above.
Safety level note: Level 1 · Review — Read-only. Can inspect and answer, never changes outside systems.
How to Add It (workspace.yaml)
kits:
- "@neusym/kit-budget@0.1.0"
domain:
seeds:
budgetScopes:
- scopeId: default
maxSteps: 40
maxCostUsd: 5.0Kits It Works With
Technical Details & Configuration Options (7 settings)
| Package | @neusym/kit-budget |
|---|---|
| Provides Ports | budget@1 |
| Requires Ports | None |
| Optional Ports | tasks@1 |
| Publishes Events | budget.exceededbudget.threshold_reachedkill_switch.changed |
| Owned DB Collections | budget_ledgers |
Configuration Options (kitConfigs.budget)
| Setting | Type | Default | Description |
|---|---|---|---|
killSwitchDefault | boolean | false | — |
tokenReservationTtlSeconds | integer | 900 | How long the tokens and cost a step reserved for its model call stay reserved when the call never settles (a crashed process), before other runs may use them. |
attemptReservationTtlSeconds | integer | 900 | Maximum lifetime of an active per-attempt reservation before it transitions to uncertain (retaining its hold until reconciled). |
maxTokensPerCall | integer | 0 | Maximum output tokens one step's model call may produce on a budgeted scope (0 means uncapped: the call may write whatever maxTokens and maxCostUsd leave once its estimated input is reserved). This is a hard per-call output ceiling, with or without maxTokens: a reply that reaches it ends with finishReason length and fails the task with MODEL_OUTPUT_TRUNCATED. |
trackUnbudgetedScopes | boolean | true | When true (default), usage observations for scopes without an explicit budget or defaultLimits automatically materialize a metering-only ledger (limits: {}) so total tokens and cost are tracked without imposing caps. |
warningThresholdRatio | number | 0.8 | Fractional budget usage ratio (0..1) that emits budget.threshold_reached once per scope and limit kind before exhaustion (0 disables). |
defaultLimits | object | — | Limits for a scope nobody set a budget for: its first live step or action creates its ledger with these. Without it, a scope with no ledger is not limited (Z10 then only proves a budget provider is bound). |