📊 Budget Hierarchy
Forge applies budgets at three scopes. A dispatch must satisfy all applicable budgets — the tightest constraint wins.BUDGET ENVELOPE HIERARCHY
Global Budget. Organization-wide ceiling
Total spend across all agents and gateways. Ultimate cost ceiling.
contains↓
Gateway Budget
Per execution surface (OpenClaw, etc.)
Gateway Budget
Per execution surface (Vercel AI, etc.)
contains↓
Agent Budget
Per-agent ceiling
Agent Budget
Per-agent ceiling
Agent Budget
Per-agent ceiling
Tightest constraint wins. All applicable budgets must pass.
📅 Budget Periods
Each budget envelope has a period that determines its reset cycle:| Period | Reset Schedule | Use Case |
|---|---|---|
daily | Midnight UTC, daily cron | Tight cost control for experimental or high-volume agents |
weekly | Sunday midnight UTC, weekly cron | Standard operational budgets with weekly review cycles |
monthly | First of month, monthly cron | Strategic budget allocation aligned with billing periods |
spentCents field and record a budget_period_reset audit event with the count of budgets reset.
An agent can have budget envelopes at multiple periods simultaneously. For example, a 200/month monthly limit. Both are checked on every dispatch, and the tightest constraint wins.
🛡️ Two Budget Gates
The governance pipeline checks budgets through two separate gates, each with different data sources:Gate 5: Agent Budget
Checks the agent’s built-in monthly budget from the agent definition document. This is the legacy budget mechanism and remains the primary per-agent cost ceiling.- Source:
agentDoc.budgetMonthlyCentsandagentDoc.spentMonthlyCents - Resolution: Prefers role-derived
resolvedBounds.maxSpendCentswhen a role is assigned, falling back to the agent’s ownbudgetMonthlyCents - Block Condition:
spentMonthlyCents >= budgetMonthlyCents - Error Code:
budget_exceeded
maxCostCents guardrail exceeds the agent’s remaining budget, the dispatch is blocked with budget_insufficient even though the current spend has not yet exceeded the ceiling.
Gate 6: Envelope Budgets
Checks all applicable budget envelopes from thebudgets table. Multiple envelopes may apply depending on scope:
- Global budgets always apply
- Gateway-scoped budgets apply when the dispatch targets that gateway
- Agent-scoped budgets apply when the dispatch uses that agent
spentCents >= amount), the gate blocks.
📋 Budget Envelope Schema
| Field | Type | Description |
|---|---|---|
scope | global / gateway / agent | Budget scope level |
scopeId | string (optional) | Gateway ID or agent ID for scoped budgets |
period | daily / weekly / monthly | Reset period |
amount | number | Budget ceiling in cents |
enabled | boolean | Whether this budget is active |
spentCents | number (optional) | Current spend in this period |
periodStart | timestamp (optional) | When the current period started |
lastResetAt | timestamp (optional) | Last period reset timestamp |
📸 Budget Snapshot
EveryGovernanceDecision includes a budgetSnapshot that captures the state of all applicable budgets at evaluation time:
💳 Token Spend Attribution
Forge tracks cost attribution through two parallel hierarchies, enabling both task-oriented and organizational budget analysis:DUAL ATTRIBUTION CHAINS
TASK CHAIN
”How much did this project cost?”
TokenIndividual LLM call
↓
TaskWorkflow step
↓
WorkflowComplete run
↓
ProjectBusiness initiative
↓
ObjectiveStrategic goal
WORKER CHAIN
”How much is this team spending?”
TokenIndividual LLM call
↓
WorkerHuman or agent
↓
TeamOrganizational unit
↓
DepartmentBusiness division
↓
CompanyOrganization total
💰 Post-Execution Cost Tracking
After every step completes (success or failure), a post-execution governance hook runs to:- Accumulate cost — Add the step’s token usage cost to the agent’s
spentMonthlyCentsand applicable budget envelopes - Check thresholds — Evaluate whether the updated spend triggers budget alerts
- Record audit event — Persist a
PostExecutionDecisionwith cost data, budget state, and any triggered actions
| Field | Description |
|---|---|
costCents | Total cost of the completed step |
tokenUsage | Input/output token counts and model used |
budgetState | Updated spend ratios for agent and all envelopes |
⚙️ Budget Management
Creating Budgets
Budgets are created through the Platform API or any connected operator interface. Each budget requires a scope and optional scopeId, a period, an amount in cents, and an enabled flag. If a budget with the same scope, scopeId, and period already exists, the upsert operation updates the existing budget rather than creating a duplicate. Requires thecost:manage permission.
Period Resets
Budget periods are reset automatically by scheduled cron jobs:| Period | Cron Schedule | What Happens |
|---|---|---|
| Daily | Daily at midnight UTC | All enabled daily budgets have spentCents zeroed |
| Weekly | Sunday midnight UTC | All enabled weekly budgets have spentCents zeroed |
| Monthly | First of month midnight UTC | All enabled monthly budgets have spentCents zeroed |
budget_period_reset audit event with the number of budgets reset.
Enabling and Disabling
Budgets can be toggled on and off without deletion. Disabled budgets are excluded from governance evaluation — the envelope budget gate only fetches enabled budgets.🔔 Budget Alerts and Auto-Pause
When the post-execution cost accumulation pushes an agent’s spend past a budget threshold, the system can:- Alert — Emit a notification at configurable threshold percentages (e.g., 80%, 90%)
- Auto-pause — When a budget is fully exhausted, subsequent dispatch attempts are blocked by the budget gate with
budget_exceeded
spentCents >= amount, the gate blocks all future dispatches for that scope and period until the budget resets or an operator increases the ceiling.
🛡️ Delegated Run Budget Protection
Delegated runs (where an agent launches a sub-run) receive additional budget scrutiny. The agent budget gate performs a headroom check: If the delegated run specifies amaxCostCents guardrail, the gate verifies that the agent’s remaining monthly budget can cover the full run ceiling. This prevents launching runs that would inevitably exceed the budget mid-execution, which would cause partial work and wasted resources.
In Burgundy: Track budgets in Analytics.

