Skip to main content

Module limit_wake

Module limit_wake 

Source
Expand description

The wake at an out-of-quota agent’s reset (SPEC_UNRESPONSIVE_AGENTS_2026_10_23.md §7). The wake at the reset (docs/specs/SPEC_UNRESPONSIVE_AGENTS_2026_10_23.md §7).

An agent whose run ended on the plan’s usage limit is limited until the provider’s reset, and Claude Code doesn’t carry on by itself in AgentMux’s stream-json sessions (no transcript shows a turn resuming after a limit error without a message). So when the reset has passed, srv wakes the pane: it clears agent:last_failure, wakes the held-jekt replay, and, if nothing is held for the agent and it holds a claimed Kanban task, tells it once to continue.

The wake is at resets_at_ms + 60 s + 0–120 s of jitter, so every agent on one account doesn’t start at the same second. One wake per resets_at_ms per pane: a limit hit again records a new failure, with a new reset. The schedule is rebuilt from block meta at start ([install]); one already due runs at once. The failure is cleared at the wake whatever the agent is doing; the note waits up to [NUDGE_PENDING_MS] for the agent to register (a pane with no process yet, or one srv’s restart resume hasn’t reached).

Constants§

AFTER_RESET_MS
How long after the reset the wake is, before the jitter.
JITTER_MS
The most jitter added.
NUDGE_PENDING_MS
How long a due note waits for its agent to register before it is dropped.

Functions§

install
Turn the wake on for this srv, and schedule one for every pane whose last run ended on a usage limit with a known reset. Until this is called (and in tests) nothing here acts.
on_failure
A failure was just stored for block_id (persist_last_failure): if it’s a usage limit, note its account (limit_evidence) and, with a reset, schedule the wake.
tell_when_registered
Tell the agent of block_id something as a system note (it starts a turn), once it has registered: a pane srv just restarted has no process yet, so this waits up to NUDGE_PENDING_MS for it instead of dropping the note. false when the agent didn’t start in time or the note didn’t go.
wake_at_ms
When the wake for a reset is, given the jitter to add.