Module: AgentHarness::Providers::RateLimitResetParsing

Included in:
Anthropic, Codex, Cursor
Defined in:
lib/agent_harness/providers/rate_limit_reset_parsing.rb

Overview

Shared rate-limit reset time parsing for providers whose CLIs emit standard reset-time formats in error output.

Include this module in any provider that uses the common format:

- "retry after 60s"        (seconds)
- "reset at 1234567890"    (unix timestamp)
- "resets 5am (UTC)"       (time today/tomorrow)
- "resets 5:00am (UTC)"    (time with minutes)
- "resets Jan 15, 5pm (UTC)" (date + time)

Providers with a different format should override parse_rate_limit_reset directly instead of including this module.

Instance Method Summary collapse

Instance Method Details

#parse_rate_limit_reset(text) ⇒ Time?

Parse rate-limit reset time from provider error output.

Parameters:

  • text (String, nil)

    error output text

Returns:

  • (Time, nil)

    UTC reset time, or nil if not parseable



22
23
24
25
26
27
28
29
# File 'lib/agent_harness/providers/rate_limit_reset_parsing.rb', line 22

def parse_rate_limit_reset(text)
  return nil unless text

  parse_retry_after(text) ||
    parse_reset_at(text) ||
    parse_resets_time(text) ||
    parse_resets_date_time(text)
end