Budgets
Token and dollar budgets with enforcement gates and human approval checkpoints.
Budgets
Budgets prevent runaway spending. Every goal can have token, dollar, and session limits — plus approval gates that pause execution and require human sign-off before continuing.
Budget Fields
Set budgets when creating a goal:
goals({
action: "create",
goal: {
title: "Ad campaign optimization",
budget: {
maxTokens: 5000000, // 5M token ceiling
maxCost: 100, // $100 total spend
maxSessions: 50, // Max 50 agent sessions
approvalGate: 50 // Pause at $50 and ask
},
// ...phases, etc.
}
})| Field | Type | Description |
|---|---|---|
maxTokens | number | Maximum tokens the goal can consume |
maxCost | number | Maximum dollar spend (token costs + external) |
maxSessions | number | Maximum agent sessions |
approvalGate | number or object | Spend level that triggers a human approval pause |
Usage is tracked automatically:
| Field | Description |
|---|---|
usedTokens | Tokens consumed so far |
usedCost | Dollars spent so far |
usedSessions | Sessions used so far |
Budget Enforcement
The budget system checks are enforced at two points:
- Phase advancement — When an agent calls
complete_phase, the budget is checked. If exceeded, advancement is blocked. - Explicit checks — Agents can call
budget_checkproactively.
Checking budget status
goals({ action: "budget_check", goalId: "g_abc123" })Response when budget is OK:
{
"allow": true,
"budgetStatus": "Budget: $12.50 / $100.00 (12.5%)",
"budget": { "maxCost": 100, "usedCost": 12.5 }
}Response when budget is exceeded:
{
"allow": false,
"reason": "cost $101.20 exceeds limit $100.00",
"remaining": -1.20,
"field": "cost"
}Recording spend
Agents record spend against a goal's budget:
goals({
action: "record_spend",
goalId: "g_abc123",
cost: {
tokens: 150000, // Tokens used this session
dollars: 2.50, // Dollar cost
sessions: 1 // One session
}
})This increments the usedTokens, usedCost, and usedSessions counters.
Approval Gates
Approval gates are the safety net for expensive goals. When spending reaches the gate threshold, the goal pauses automatically and notifies the user.
How it works
- Goal budget includes
approvalGate: 50(pause at $50) - Agent records spend that crosses the threshold
- Budget check returns
gateReached: true - Goal is paused with message: "Approval required: cost $51.20 reached gate threshold $50.00"
- Human reviews and approves
Approving a goal
Via CLI:
reeve goal approve <goal-id>Via agent tool:
goals({ action: "approve", goalId: "g_abc123" })What happens on approval
Approval doesn't just unlock — it raises the gate by 50%:
- Gate was $50 → now $75
- Gate was $75 → now $112.50
- This lets the goal continue without immediately hitting the gate again
If the goal was paused, it's automatically resumed after approval.
Object-form approval gates
For fine-grained control, set the gate as an object:
budget: {
maxCost: 200,
maxTokens: 10000000,
approvalGate: {
cost: 50, // Pause at $50
tokens: 5000000 // Also pause at 5M tokens
}
}Either threshold being reached triggers the pause.
Budget Status Formatting
The engine provides human-readable budget summaries:
Budget: $12.50 / $100.00 (12.5%) | 1.2M / 5M tokens (24%) | Gate: $50This appears in:
- Goal context injection (agent sees it in heartbeats)
- CLI
reeve goal statusoutput - Dashboard goal detail view
Budget enforcement blocks phase advancement, not individual agent actions. An agent can still send messages and use tools while over budget — it just can't call complete_phase to advance the goal. This prevents interrupting in-progress work while still enforcing limits at transition points.
Example: Progressive Budget with Gates
goals({
action: "create",
goal: {
title: "Full-funnel marketing sprint",
budget: {
maxCost: 500, // Hard ceiling: $500
maxTokens: 50000000, // 50M tokens
approvalGate: 100 // First gate at $100
},
phases: [
{ name: "Research & plan", type: "once" }, // ~$10
{ name: "Build creatives", type: "once" }, // ~$30
{ name: "Launch campaigns", type: "once" }, // ~$50
{ name: "Monitor & optimize", type: "loop" } // ~$10/day
]
}
})Expected flow:
- Research + build ≈ $40 → under gate, no pause
- Launch campaigns pushes to $90 → under gate, no pause
- Monitoring pushes to $105 → gate hit, goal pauses
- Human approves → gate raises to $150, goal resumes
- Monitoring continues to $155 → gate hit again
- Human approves → gate raises to $225, goal resumes
- Eventually completes under $500 ceiling