Exception: Aidp::Harness::UsageLimitExceededError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/aidp/harness/usage_limit_enforcer.rb

Overview

Exception raised when usage limits are exceeded Contains context about the exceeded limit for fallback handling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider_name:, tier:, current_tokens:, current_cost:, max_tokens:, max_cost:, period_description:, message: nil) ⇒ UsageLimitExceededError

Returns a new instance of UsageLimitExceededError.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aidp/harness/usage_limit_enforcer.rb', line 14

def initialize(provider_name:, tier:, current_tokens:, current_cost:,
  max_tokens:, max_cost:, period_description:, message: nil)
  @provider_name = provider_name
  @tier = tier
  @current_tokens = current_tokens
  @current_cost = current_cost
  @max_tokens = max_tokens
  @max_cost = max_cost
  @period_description = period_description

  super(message || default_message)
end

Instance Attribute Details

#current_costObject (readonly)

Returns the value of attribute current_cost.



11
12
13
# File 'lib/aidp/harness/usage_limit_enforcer.rb', line 11

def current_cost
  @current_cost
end

#current_tokensObject (readonly)

Returns the value of attribute current_tokens.



11
12
13
# File 'lib/aidp/harness/usage_limit_enforcer.rb', line 11

def current_tokens
  @current_tokens
end

#max_costObject (readonly)

Returns the value of attribute max_cost.



11
12
13
# File 'lib/aidp/harness/usage_limit_enforcer.rb', line 11

def max_cost
  @max_cost
end

#max_tokensObject (readonly)

Returns the value of attribute max_tokens.



11
12
13
# File 'lib/aidp/harness/usage_limit_enforcer.rb', line 11

def max_tokens
  @max_tokens
end

#period_descriptionObject (readonly)

Returns the value of attribute period_description.



11
12
13
# File 'lib/aidp/harness/usage_limit_enforcer.rb', line 11

def period_description
  @period_description
end

#provider_nameObject (readonly)

Returns the value of attribute provider_name.



11
12
13
# File 'lib/aidp/harness/usage_limit_enforcer.rb', line 11

def provider_name
  @provider_name
end

#tierObject (readonly)

Returns the value of attribute tier.



11
12
13
# File 'lib/aidp/harness/usage_limit_enforcer.rb', line 11

def tier
  @tier
end

Instance Method Details

#to_hObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/aidp/harness/usage_limit_enforcer.rb', line 27

def to_h
  {
    type: "usage_limit_exceeded",
    provider: @provider_name,
    tier: @tier,
    current_tokens: @current_tokens,
    current_cost: @current_cost,
    max_tokens: @max_tokens,
    max_cost: @max_cost,
    period: @period_description,
    timestamp: Time.now.iso8601
  }
end