class RubyLLM::Browser::Budget
Immutable limits for a single browser operation.
A budget is deliberately conservative. Elapsed time, steps and bytes are separate limits, and a projected or estimated cost is never presented as a provider-enforced hard billing cap. When a limit is unknown or exhausted the Gem refuses more work rather than guessing.
Constants
- DEFAULT_MAX_BYTES
- DEFAULT_MAX_CONCURRENT
- DEFAULT_MAX_SECONDS
- DEFAULT_MAX_STEPS
Attributes
max_bytes[R]
max_concurrent[R]
max_cost_usd[R]
max_seconds[R]
max_steps[R]
Public Class Methods
new(max_seconds: DEFAULT_MAX_SECONDS, max_steps: DEFAULT_MAX_STEPS, max_bytes: DEFAULT_MAX_BYTES, max_concurrent: DEFAULT_MAX_CONCURRENT, max_cost_usd: nil)
click to toggle source
@param max_seconds [Numeric] wall-clock ceiling for the operation @param max_steps [Integer] maximum provider round-trips (navigate/observe/…) @param max_bytes [Integer] maximum bytes of page/result content kept per operation @param max_concurrent [Integer] concurrent sessions allowed for the actor @param max_cost_usd [Numeric, nil] advisory cost reservation; nil means unknown
# File lib/ruby_llm/browser/budget.rb, line 24 def initialize(max_seconds: DEFAULT_MAX_SECONDS, max_steps: DEFAULT_MAX_STEPS, max_bytes: DEFAULT_MAX_BYTES, max_concurrent: DEFAULT_MAX_CONCURRENT, max_cost_usd: nil) @max_seconds = positive_number!(max_seconds, :max_seconds) @max_steps = positive_integer!(max_steps, :max_steps) @max_bytes = positive_integer!(max_bytes, :max_bytes) @max_concurrent = positive_integer!(max_concurrent, :max_concurrent) @max_cost_usd = max_cost_usd.nil? ? nil : non_negative_number!(max_cost_usd, :max_cost_usd) freeze end
Public Instance Methods
==(other)
click to toggle source
# File lib/ruby_llm/browser/budget.rb, line 50 def ==(other) other.is_a?(Budget) && to_h == other.to_h end
Also aliased as: eql?
digest()
click to toggle source
# File lib/ruby_llm/browser/budget.rb, line 46 def digest Redactor.digest(to_h) end
hash()
click to toggle source
# File lib/ruby_llm/browser/budget.rb, line 55 def hash to_h.hash end
inspect()
click to toggle source
# File lib/ruby_llm/browser/budget.rb, line 59 def inspect "#<#{self.class} seconds=#{max_seconds} steps=#{max_steps} bytes=#{max_bytes} concurrent=#{max_concurrent}>" end
to_h()
click to toggle source
# File lib/ruby_llm/browser/budget.rb, line 36 def to_h { max_seconds: max_seconds, max_steps: max_steps, max_bytes: max_bytes, max_concurrent: max_concurrent, max_cost_usd: max_cost_usd } end