From 06176201da2709858a60210790a77de16fb840be Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 8 Apr 2026 09:35:52 -0400 Subject: [PATCH] Fix bail script: pass own pid file so it can exclude itself MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The bail-no-competing.sh script expects $1 to be the path to the current agent's pid file so it can skip it when checking for competing processes. But the runner wasn't passing any arguments, so $1 was empty and the script treated every pid file (including the agent's own) as a competing process — bailing every time. This caused surface-observe to always bail at step 2, preventing all memory graph maintenance (organize, observe phases) from running. Co-Authored-By: Proof of Concept --- src/agent/oneshot.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/agent/oneshot.rs b/src/agent/oneshot.rs index 6ab79ca..2332d27 100644 --- a/src/agent/oneshot.rs +++ b/src/agent/oneshot.rs @@ -474,9 +474,13 @@ pub fn run_one_agent( // Bail check: if the agent defines a bail script, run it between steps. let bail_script = def.bail.as_ref().map(|name| defs::agents_dir().join(name)); let state_dir_for_bail = state_dir.clone(); + // Find our own pid file so we can pass it to the bail script + let our_pid = std::process::id(); + let our_pid_file = format!("pid-{}", our_pid); let bail_fn = move |step_idx: usize| -> Result<(), String> { if let Some(ref script) = bail_script { let status = std::process::Command::new(script) + .arg(&our_pid_file) .current_dir(&state_dir_for_bail) .status() .map_err(|e| format!("bail script {:?} failed: {}", script, e))?;