Skip to main content

Module cost_budget

Module cost_budget 

Source
Expand description

Per-scope cost budgets + spend aggregation (CH-06, fable §R11 / §7).

Builds on the existing opt-in cost estimation (LlmConfig.cost_tracking, estimate_cost, the uar_llm_cost_usd metric). This module adds the accounting layer the runtime was missing: aggregate spend per run / task / session / agent, declare budget envelopes, and emit threshold-crossing events so the UI and operators can react before a runaway burns the budget.

The synchronous tracker measures live activity; the trusted driver wrapper reserves and settles durable aggregate liability before exposing provider events.

Structs§

BudgetLimit
A configured budget limit for one (scope, scope_id).
ClientToolBudgetSnapshot
Immutable local-accounting evidence retained across a caller-tool handoff. Durable monetary liabilities remain in the existing accounting store.
CostBudgetTracker
Thread-safe cost-budget tracker. Cloneable handle over shared state.

Enums§

BudgetScope
The dimension a budget / spend record is keyed on.
BudgetStatus
Result of recording spend against a budget.