From e6b53513d4723239e2bac1aac00e23e3325dd434 Mon Sep 17 00:00:00 2001 From: mfowler Date: Tue, 23 Jun 2026 05:17:07 +0000 Subject: [PATCH] feat(wake): re-run one-shot task agents on their wake interval (autonomous cadence) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wake_agent only re-prompted a live persistent/loop session and returned False for a dead one, so a "task" agent (one-shot, exits after its run) could not be re-run on a schedule — its wake never fired. Now, for kind=="task", a wake kills+restarts the task for a clean re-run (skipping only while its previous run is still active). This makes scheduled work like a coverage audit recur autonomously, no operator trigger. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01UWTdUq2bsic7JZGqJp3nD6 --- agents.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/agents.py b/agents.py index 733429e..3996e67 100755 --- a/agents.py +++ b/agents.py @@ -578,6 +578,15 @@ def wake_agent(cfg, agent): if not wake: return True session = agent["session"] + # A one-shot `task` is "woken" by RE-RUNNING it fresh — it has no persistent REPL to re-prompt — so + # scheduled work (e.g. a coverage audit) recurs autonomously on its interval, no operator needed. + # Skip only while its previous run is still going; otherwise kill + restart for a clean re-run. + if agent.get("kind") == "task": + if session_alive(session) and pane_active(cfg, agent, capture_pane(session, 25)): + return False + log(f"wake: re-running task {agent['name']} ({session})") + start_agent(cfg, agent, force=True) + return True if not session_alive(session): return False backend = backend_of(cfg, agent)