fix: scope Stop hook to per-agent — prevents killing orchestrating CC session
This commit is contained in:
15
loop.sh
15
loop.sh
@@ -148,7 +148,8 @@ cd "$PROJECT_ROOT"
|
||||
|
||||
cleanup() {
|
||||
[ -n "${LOOP_AGENT_TMPFILE:-}" ] && rm -f "$LOOP_AGENT_TMPFILE"
|
||||
[ "$AUTO_HOOKS" = true ] && remove_hooks
|
||||
# Remove hooks in case we exit mid-agent (Ctrl+C during a claude session)
|
||||
[ "$AUTO_HOOKS" = true ] && remove_hooks 2>/dev/null
|
||||
release_lock
|
||||
}
|
||||
|
||||
@@ -178,9 +179,8 @@ finish() {
|
||||
}
|
||||
LOOP_AGENT_TMPFILE=""
|
||||
|
||||
if [ "$AUTO_HOOKS" = true ]; then
|
||||
install_hooks
|
||||
fi
|
||||
# NOTE: Stop hook is installed/removed per-agent in run_agent(), not globally.
|
||||
# This prevents the hook from killing the orchestrating CC session.
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
check_archive
|
||||
@@ -231,8 +231,10 @@ run_agent() {
|
||||
local agent_exit=0
|
||||
if [ "${LOOP_HEADLESS:-false}" != "true" ]; then
|
||||
# --- Interactive mode (Ralph pattern) ---
|
||||
# Pipe prompt to claude without --print — full interactive UI.
|
||||
# The Stop hook handles session exit.
|
||||
# Install Stop hook just before claude starts, remove after it exits.
|
||||
# This scopes the hook to only affect the loop's claude sessions.
|
||||
[ "$AUTO_HOOKS" = true ] && install_hooks
|
||||
|
||||
(
|
||||
case "$TOOL" in
|
||||
claude)
|
||||
@@ -248,6 +250,7 @@ run_agent() {
|
||||
esac
|
||||
) || agent_exit=$?
|
||||
|
||||
[ "$AUTO_HOOKS" = true ] && remove_hooks
|
||||
sleep 2 # Brief pause between sessions
|
||||
|
||||
# Read verdict from file if evaluator wrote one
|
||||
|
||||
Reference in New Issue
Block a user