class

Autobot::Tools::RateLimiter

Inherits Reference < Object

Constants

DEFAULT_SESSION_LIMIT = Limit.new(max_calls: 30, window_seconds: 60)
Log = ::Log.for(self)

Constructors

from_config(config : Config::RateLimitConfig | Nil) : RateLimiter

Factory method to create from config

Source
new(per_tool_limits : Hash(String, Autobot::Tools::RateLimiter::Limit) = {} of String => Limit, global_limit : Limit | Nil = nil, session_limit : Limit = DEFAULT_SESSION_LIMIT)
Source

Instance methods

check_limit(tool_name : String, session_key : String) : String | Nil

Check if a tool call is allowed Returns nil if allowed, error message if rate limited

Source
current_count(key : String) : Int32

Get current call count for a key (for monitoring)

Source
record_call(tool_name : String, session_key : String) : Nil

Record a successful tool call

Source
reset

Reset rate limits (useful for testing)

Source

Nested types