pub struct Budget {
pub max_input_tokens: Option<u64>,
pub max_output_tokens: Option<u64>,
pub max_total_tokens: Option<u64>,
pub max_tool_calls: Option<u32>,
pub max_wall_time_ms: Option<u64>,
pub max_cost_cents: Option<u64>,
}Expand description
Budget limits for a run
Fields§
§max_input_tokens: Option<u64>Maximum input tokens allowed
max_output_tokens: Option<u64>Maximum output tokens allowed
max_total_tokens: Option<u64>Maximum total tokens (input + output)
max_tool_calls: Option<u32>Maximum number of tool calls
max_wall_time_ms: Option<u64>Maximum wall time in milliseconds
max_cost_cents: Option<u64>Maximum cost in cents (USD)
Implementations§
Source§impl Budget
impl Budget
Sourcepub fn has_cost_headroom(
&self,
usage: &BudgetUsage,
additional_cents: u64,
) -> bool
pub fn has_cost_headroom( &self, usage: &BudgetUsage, additional_cents: u64, ) -> bool
Whether spending additional_cents on top of the current usage would
still fit under the cost cap. true when no cost cap is configured.
Used by the reversibility ladder’s R2 rung: a Costly tool call is
allowed under budget while this returns true, and escalates to an
approval gate once it returns false.
Sourcepub fn cost_remaining_cents(&self, usage: &BudgetUsage) -> Option<u64>
pub fn cost_remaining_cents(&self, usage: &BudgetUsage) -> Option<u64>
Cost headroom remaining under the cap, in cents. None when no cost cap
is configured (unbounded). Saturates at 0 once the cap is met/exceeded.
Emitted as ferrumdeck.budget_remaining on the enforcement-decision
GenAI span (see fd_otel::decision) so an operator can see how close a
run was to the budget circuit breaker at the moment of each decision.