From 6f398227d9242951f5bd0a0f2dce32c9f96c5395 Mon Sep 17 00:00:00 2001 From: shiva Date: Fri, 7 Aug 2026 12:23:20 +0530 Subject: [PATCH] fix(supervisor): dispatched jobs inherit the wrong timeout (300s, not work's own 1800s) agentflare work's own --timeout flag defaults to 1800s (its real budget for a headless agent run), but dispatch_item never set a timeout on the outer agentflare_jobs::AgentJob it enqueues, so it fell back to that crate's generic 300s default -- killing every dispatched job at 5 minutes without the inner, correctly-tuned 30-minute budget ever coming into play. Found live: item #13 timed out at exactly 300s twice in a row while dogfooding items #15-#17, even after both of those fixes landed. --- src/supervisor.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/supervisor.rs b/src/supervisor.rs index 11d6d320..f391afef 100644 --- a/src/supervisor.rs +++ b/src/supervisor.rs @@ -10,6 +10,12 @@ const DISPATCHED_LABEL: &str = "dispatched"; const NEEDS_MANUAL_LABEL: &str = "needs-manual-dispatch"; const NEEDS_HUMAN_GATE_LABEL: &str = "needs-human-gate"; +/// `agentflare work`'s own `--timeout` defaults to 1800s (its real budget +/// for a headless agent run) -- this is that budget plus margin for the +/// claim/worktree setup and done/push/PR steps around it, so the outer job +/// timeout never cuts off a run before work's own inner timeout would. +const WORK_JOB_TIMEOUT_SECS: u64 = 2100; + /// Returns the matching `Agent` only if `agent_registry::autonomous_args` /// confirms it has a headless permission-bypass flag — the same gate /// `agentflare work` itself uses (`src/cli/work.rs`'s `run_work`). @@ -172,12 +178,14 @@ fn dispatch_item( let command = std::env::current_exe() .map(|p| p.to_string_lossy().to_string()) .unwrap_or_else(|_| "agentflare".to_string()); - let job = agentflare_jobs::AgentJob::new(command).args([ - "work".to_string(), - item.id.clone(), - "--agent".to_string(), - agent.as_str().to_string(), - ]); + let job = agentflare_jobs::AgentJob::new(command) + .args([ + "work".to_string(), + item.id.clone(), + "--agent".to_string(), + agent.as_str().to_string(), + ]) + .timeout(WORK_JOB_TIMEOUT_SECS); let Ok(info) = queue.enqueue(&job) else { return false; };