From 54ea7824d8b17e7ea2b8875a241149efa2b2e898 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 2 Apr 2026 01:15:37 -0400 Subject: [PATCH] Fix agent log path: only set state on spawn, not scan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent state (pid, phase, log_path) only updates when we spawn an agent. The scan_pid_files path no longer calls update_agent — it just logs. This prevents the scan path from clearing log_path with None on subsequent triggers. Co-Authored-By: Proof of Concept --- src/subconscious/hook.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/subconscious/hook.rs b/src/subconscious/hook.rs index 6d4b4bd..cc21be0 100644 --- a/src/subconscious/hook.rs +++ b/src/subconscious/hook.rs @@ -192,9 +192,7 @@ impl AgentCycleState { if let Some(agent) = self.agents.iter_mut().find(|a| a.name == name) { agent.pid = pid; agent.phase = phase; - if log_path.is_some() { - agent.log_path = log_path; - } + agent.log_path = log_path; } } @@ -271,11 +269,8 @@ impl AgentCycleState { .unwrap_or(300) as u64; let live = crate::agents::knowledge::scan_pid_files(&state_dir, timeout); - if let Some((phase, pid)) = live.first() { - self.update_agent("surface-observe", Some(*pid), Some(phase.clone()), None); + for (phase, pid) in &live { self.log(format_args!("alive pid-{}: phase={}\n", pid, phase)); - } else { - self.update_agent("surface-observe", None, None, None); } // Read surfaced keys @@ -360,7 +355,6 @@ impl AgentCycleState { let live = crate::agents::knowledge::scan_pid_files(&state_dir, 300); if let Some((phase, pid)) = live.first() { - self.update_agent("reflect", Some(*pid), Some(phase.clone()), None); self.log(format_args!("reflect: already running pid {}\n", pid)); return None; } @@ -406,7 +400,6 @@ impl AgentCycleState { let live = crate::agents::knowledge::scan_pid_files(&state_dir, 300); if let Some((phase, pid)) = live.first() { - self.update_agent("journal", Some(*pid), Some(phase.clone()), None); self.log(format_args!("journal: already running pid {}\n", pid)); return; }