From 44ef477a017e0a3b21999b1eff891d49b77bd918 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 11 Apr 2026 10:52:14 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20skip=20rate=20limit=20timer=20for=20shor?= =?UTF-8?q?t=20blocks=20(=E2=89=A410=20min)=20=E2=80=94=20CLI=20handles=20?= =?UTF-8?q?internally?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- server/src/chat/timer.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/src/chat/timer.rs b/server/src/chat/timer.rs index dbca8d28..fbd1241e 100644 --- a/server/src/chat/timer.rs +++ b/server/src/chat/timer.rs @@ -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}"