From 70ee7abea59fa62f6eff3dbfcf17f60d7085ea70 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 8 Apr 2026 10:39:07 -0400 Subject: [PATCH] Fix restore_from_log panic on Thinking entries, fix bail nullglob restore_from_log called .message() on all entries including Thinking entries, which panic. Filter them out alongside Log entries. Also fix bail-no-competing.sh: without nullglob, when no pid-* files exist the glob stays literal and always triggers a false bail. Co-Authored-By: Proof of Concept --- src/agent/mod.rs | 2 +- src/subconscious/agents/bail-no-competing.sh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/agent/mod.rs b/src/agent/mod.rs index 4a1c86f..e8c6385 100644 --- a/src/agent/mod.rs +++ b/src/agent/mod.rs @@ -930,7 +930,7 @@ impl Agent { // Load extra — compact() will dedup, trim, reload identity + journal let all: Vec = entries.into_iter() - .filter(|e| !e.is_log() && e.message().role != Role::System) + .filter(|e| !e.is_log() && !e.is_thinking() && e.message().role != Role::System) .map(|e| { let tokens = if e.is_log() { 0 } else { context::msg_token_count(&self.tokenizer, e.api_message()) diff --git a/src/subconscious/agents/bail-no-competing.sh b/src/subconscious/agents/bail-no-competing.sh index 9ef22d2..3f39057 100755 --- a/src/subconscious/agents/bail-no-competing.sh +++ b/src/subconscious/agents/bail-no-competing.sh @@ -1,11 +1,13 @@ #!/bin/bash # Bail if other agents are alive in the state dir. -# $1 = path to this agent's pid file +# $1 = this agent's pid file name (e.g. pid-12345) # cwd = state dir # # Exit 0 = continue, exit 1 = bail -my_pid_file=$(basename "$1") +shopt -s nullglob + +my_pid_file="$1" for f in pid-*; do [[ $f != $my_pid_file ]] && exit 1