Exception: RubyLLM::Agents::Reliability::BudgetExceededError

Inherits:
Error
  • Object
show all
Defined in:
lib/ruby_llm/agents/infrastructure/reliability.rb

Overview

Raised when budget limits have been exceeded

Examples:

raise BudgetExceededError.new(:global_daily, 25.0, 27.5)

With tenant

raise BudgetExceededError.new(:global_daily, 25.0, 27.5, tenant_id: "acme")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, limit, current, agent_type: nil, tenant_id: nil) ⇒ BudgetExceededError

Returns a new instance of BudgetExceededError.

Parameters:

  • scope (Symbol)

    The budget scope (:global_daily, :global_monthly, :per_agent_daily, etc.)

  • limit (Float)

    The budget limit in USD

  • current (Float)

    The current spend in USD

  • agent_type (String, nil) (defaults to: nil)

    The agent type for per-agent budgets

  • tenant_id (String, nil) (defaults to: nil)

    The tenant identifier for multi-tenant budgets



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ruby_llm/agents/infrastructure/reliability.rb', line 57

def initialize(scope, limit, current, agent_type: nil, tenant_id: nil)
  @scope = scope
  @limit = limit
  @current = current
  @agent_type = agent_type
  @tenant_id = tenant_id

  message = "Budget exceeded for #{scope}"
  message += " (tenant: #{tenant_id})" if tenant_id
  message += " (#{agent_type})" if agent_type
  message += ": limit $#{limit}, current $#{current}"
  super(message)
end

Instance Attribute Details

#agent_typeObject (readonly)



50
51
52
# File 'lib/ruby_llm/agents/infrastructure/reliability.rb', line 50

def agent_type
  @agent_type
end

#currentObject (readonly)



50
51
52
# File 'lib/ruby_llm/agents/infrastructure/reliability.rb', line 50

def current
  @current
end

#limitObject (readonly)



50
51
52
# File 'lib/ruby_llm/agents/infrastructure/reliability.rb', line 50

def limit
  @limit
end

#scopeObject (readonly)



50
51
52
# File 'lib/ruby_llm/agents/infrastructure/reliability.rb', line 50

def scope
  @scope
end

#tenant_idObject (readonly)



50
51
52
# File 'lib/ruby_llm/agents/infrastructure/reliability.rb', line 50

def tenant_id
  @tenant_id
end