From 85fffd9fb78b68aab1266c540a2aceffb0d298db Mon Sep 17 00:00:00 2001 From: openhands Date: Sat, 21 Mar 2026 11:22:07 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20CI=20fix=20counter=20can=20be=20wasted?= =?UTF-8?q?=20by=20guard=20hits=20=E2=80=94=20consider=20check=5Fonly=20mo?= =?UTF-8?q?de=20(#377)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Orphan and stuck-PR CI-failure paths in dev-poll.sh called handle_ci_exhaustion without check_only, incrementing the fix counter on every poll cycle even when guards (session checks, is_blocked) prevented an actual agent launch. This could exhaust the 3-attempt budget without any real fix attempts. Now both paths use the same two-phase pattern as the backlog scan: 1. check_only during the scan (no counter increment) 2. Increment atomically at actual launch time Co-Authored-By: Claude Opus 4.6 (1M context) --- dev/dev-poll.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dev/dev-poll.sh b/dev/dev-poll.sh index ebf46cd..09387a5 100755 --- a/dev/dev-poll.sh +++ b/dev/dev-poll.sh @@ -375,10 +375,14 @@ if [ "$ORPHAN_COUNT" -gt 0 ]; then log "issue #${ISSUE_NUM} already has active session ${SESSION_NAME} — skipping" exit 0 fi - if handle_ci_exhaustion "$HAS_PR" "$ISSUE_NUM"; then + if handle_ci_exhaustion "$HAS_PR" "$ISSUE_NUM" "check_only"; then # Fall through to backlog scan instead of exit : else + # Increment at actual launch time (not on guard-hit paths) + if handle_ci_exhaustion "$HAS_PR" "$ISSUE_NUM"; then + exit 0 # exhausted between check and launch + fi log "issue #${ISSUE_NUM} PR #${HAS_PR} CI failed — spawning agent to fix (attempt ${CI_FIX_ATTEMPTS}/3)" nohup "${SCRIPT_DIR}/dev-agent.sh" "$ISSUE_NUM" >> "$LOGFILE" 2>&1 & log "started dev-agent PID $! for issue #${ISSUE_NUM} (CI fix)" @@ -483,9 +487,13 @@ for i in $(seq 0 $(($(echo "$OPEN_PRS" | jq 'length') - 1))); do log "issue #${STUCK_ISSUE} already has active session ${SESSION_NAME} — skipping" continue fi - if handle_ci_exhaustion "$PR_NUM" "$STUCK_ISSUE"; then + if handle_ci_exhaustion "$PR_NUM" "$STUCK_ISSUE" "check_only"; then continue # skip this PR, check next stuck PR or fall through to backlog fi + # Increment at actual launch time (not on guard-hit paths) + if handle_ci_exhaustion "$PR_NUM" "$STUCK_ISSUE"; then + continue # exhausted between check and launch + fi log "PR #${PR_NUM} (issue #${STUCK_ISSUE}) CI failed — fixing (attempt ${CI_FIX_ATTEMPTS}/3)" nohup "${SCRIPT_DIR}/dev-agent.sh" "$STUCK_ISSUE" >> "$LOGFILE" 2>&1 & log "started dev-agent PID $! for stuck PR #${PR_NUM}"