Module: RobotLab::Robot::Budget
- Defined in:
- lib/robot_lab/robot/budget.rb
Overview
Token/cost budget enforcement for a single Robot, backed by a RobotLab::Budget::Ledger.
Two layers of enforcement:
- reserve_budget!/reconcile_budget! wrap each LLM call. reserve_budget! raises BudgetExceeded up front when a prior call already pushed usage over budget, so a robot with an exhausted budget refuses further calls instead of spending on them.
- enforce_token_budget!/enforce_cost_budget! run after the call completes and raise InferenceError when this call's actual usage pushed cumulative usage over budget — unavoidable for the call that causes the overage, since token/cost totals aren't known until the response comes back.