Skip to main content

Module limit_reset

Module limit_reset 

Source
Expand description

When an agent’s usage limit lifts: AgentFailure::resets_at_ms and limit_window, filled in when a UsageLimit failure is stored (docs/specs/SPEC_UNRESPONSIVE_AGENTS_2026_10_23.md §3.4).

The sources, in order:

  1. Claude’s rate_limit_event, whose status is exactly "rejected": Claude Code sends one with every request, and a rejected one comes just before the limit error, carrying the exhausted window’s resetsAt (unix seconds) and rateLimitType. The persistent stdout reader hands every frame to observe_frame, which keeps the latest per block. overageStatus is often "rejected" while status is "allowed"; it is never read.
  2. The error text, resets Oct 26, 7pm (America/Los_Angeles) or resets 3:10am (UTC) or resets 7pm, read in the zone it names (any IANA name or UTC, from the chrono-tz data) or, with none, in this machine’s own; a zone that is not a name is left unknown. Codex words it ... or try again at 9:44 PM. (the machine’s own zone, with the date and year when it is not today: Nov 3rd, 2025 9:44 PM); codex_failure_text picks that text out of Codex’s error and turn.failed frames.

A reset outside (now, now + 8 days] is dropped: an unknown reset still leaves the agent limited, just with no time shown.

Structs§

RateLimitInfo
A rate_limit_event’s rate_limit_info, the fields this reads.

Functions§

assistant_error_evidence
What a synthetic assistant message says failed, for the result frame that ends its turn: Claude Code writes the cause there ("error": "rate_limit" with “You’ve hit your 5-hour limit · resets 8:10pm”, authentication_failed) and its result frame carries only a generic error. A login failure keeps its fixed word; any other message with an error field gives that field and its text; an ordinary assistant message gives nothing.
codex_failure_text
The message of a Codex error or turn.failed frame, or None for any other frame and for the Reconnecting... retry notices, which are not failures.
fill_reset
with_reset’s rule, with its inputs passed in.
forget
Forget block_id’s rate-limit info: its pane closed (blockcontroller::release_block_processes).
inband_error_text
What classify should read from a frame the stdout reader kept as the run’s in-band error: a Claude synthetic assistant message, or a Codex failure.
is_login_failure_frame
Whether frame is the synthetic assistant message Claude Code writes when the login failed ("error": "authentication_failed"). The result frame that ends the turn carries only prose (“Failed to authenticate: OAuth session expired and could not be refreshed”), so this is what tells an expired login from any other failure whatever the wording.
observe_frame
Keep frame as block_id’s latest rate-limit info if it is a rate_limit_event; any other frame is ignored.
reset_from_text
The reset a limit message names (resets Oct 26, 7pm (America/Los_Angeles), resets 7:30pm, resets 3:10am (UTC)), in unix ms, or None. A named zone is read as that zone’s clock (local_zone is this machine’s, read as local); with none named the time is local (the CLI writes it in the machine’s zone). A time with no date is its next occurrence after now; a date with no year, likewise.
with_reset
failure with its reset filled in from what is known for block_id, at this machine’s clock and time zone. Unchanged unless it is a UsageLimit with no reset yet.