orka.orchestrator.budget_controller module

Budget Controller

Budget management and constraint enforcement for path selection. Monitors and controls resource usage including tokens, cost, and latency.

class orka.orchestrator.budget_controller.BudgetController(config: Any)[source]

Bases: object

Resource budget management and enforcement.

Manages and enforces constraints on: - Token usage - Cost limits (USD) - Latency budgets (milliseconds) - Memory usage

__init__(config: Any)[source]

Initialize budget controller with configuration.

async filter_candidates(candidates: List[Dict[str, Any]], context: Dict[str, Any]) List[Dict[str, Any]][source]

Filter candidates based on budget constraints.

Parameters:
  • candidates – List of candidate paths

  • context – Execution context

Returns:

List of candidates that fit within budget

async update_usage(tokens_used: int, cost_incurred: float, latency_ms: float) None[source]

Update current resource usage.

get_usage_summary() Dict[str, Any][source]

Get current usage summary.

is_budget_exhausted(threshold: float = 0.9) bool[source]

Check if budget is nearly exhausted.