fix: skip rate limit timer for short blocks (≤10 min) — CLI handles internally

The rate limit auto-scheduler was creating timers for every hard block,
including short 5-minute throttles. This caused a death loop: agent hits
rate limit, timer set, agent exits, pipeline restarts before timer fires,
new agent dies instantly (Session: None) because API is still throttled.

Short rate limits are handled naturally by the CLI's internal wait. Only
schedule timers for long session-level blocks (>10 min) where the CLI
will exit and needs external restart.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dave
2026-04-11 10:52:14 +00:00
parent de738b27ed
commit 44ef477a01
+12
View File
@@ -255,6 +255,18 @@ pub fn spawn_rate_limit_auto_scheduler(
agent_name,
reset_at,
}) => {
// Skip short rate limits (≤10 min) — the CLI handles
// these internally. Only schedule timers for long
// session-level blocks where the CLI will exit.
let until_reset = reset_at.signed_duration_since(chrono::Utc::now());
if until_reset.num_minutes() <= 10 {
crate::slog!(
"[timer] Skipping short rate limit for {story_id} \
({} min); CLI will handle internally",
until_reset.num_minutes()
);
continue;
}
crate::slog!(
"[timer] Auto-scheduling timer for story {story_id} \
(agent {agent_name}) to resume at {reset_at}"