loopd: scheduler yields to a held subagent

Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
2026-10-03 20:03:13 -07:00
co-authored by ornith-1.5-35b-a3b
parent 4491e1b80d
commit 79735b21e4
4 changed files with 102 additions and 0 deletions
+6
View File
@@ -59,6 +59,12 @@ impl Context {
drop(busy);
Ok(Held { ctx: self, id })
}
/// True when any held session id starts with `prefix` (`sub-` for a live child).
pub fn holds_prefix(&self, prefix: &str) -> bool {
let busy = self.busy.lock().unwrap_or_else(|p| p.into_inner());
busy.iter().any(|id| id.as_str().starts_with(prefix))
}
}
/// While a turn runs, the session is in the busy set. The guard holds only an immutable borrow of
+6
View File
@@ -43,6 +43,9 @@ impl Scheduler {
self.leftovers_closed = true;
}
self.heartbeat(ctx, now, &mut work);
if ctx.holds_prefix("sub-") {
return work;
}
let jobs_dir = ctx.cfg.paths.home.join("jobs");
let runs_path = jobs_dir.join("runs.jsonl");
@@ -184,6 +187,9 @@ impl Scheduler {
if !due {
return;
}
if ctx.holds_prefix("sub-") {
return;
}
let id = match SessionId::new("heartbeat") {
Ok(id) => id,