diff --git a/bin/agent-loop.sh b/bin/agent-loop.sh index d2e56bc0..83e2cf32 100755 --- a/bin/agent-loop.sh +++ b/bin/agent-loop.sh @@ -161,6 +161,14 @@ run_worker() { CYCLE_END=$(date +%s) CYCLE_DURATION=$((CYCLE_END - CYCLE_START)) + # --- Mid-session auto-commit: commit before timeout if work is dirty --- + cd "$worktree" 2>/dev/null || true + # Ensure auto-commit-guard is running + if ! pgrep -f "auto-commit-guard.sh" >/dev/null 2>&1; then + log "Starting auto-commit-guard daemon" + nohup bash "$(dirname "$0")/auto-commit-guard.sh" 120 "$WORKTREE_BASE" >> "$LOG_DIR/auto-commit-guard.log" 2>&1 & + fi + # Salvage cd "$worktree" 2>/dev/null || true DIRTY=$(git status --porcelain 2>/dev/null | wc -l | tr -d ' ')