fix: fix: agent_run nudges unnecessarily when worktree is clean and no push expected (#219) #223

Merged
dev-qwen merged 1 commit from fix/issue-219 into main 2026-04-05 14:58:45 +00:00

View file

@ -72,13 +72,10 @@ agent_run() {
local has_pushed local has_pushed
has_pushed=$(cd "$run_dir" && git log --oneline "${FORGE_REMOTE:-origin}/${PRIMARY_BRANCH:-main}..HEAD" 2>/dev/null | head -1) || true has_pushed=$(cd "$run_dir" && git log --oneline "${FORGE_REMOTE:-origin}/${PRIMARY_BRANCH:-main}..HEAD" 2>/dev/null | head -1) || true
if [ -z "$has_pushed" ]; then if [ -z "$has_pushed" ]; then
local nudge="You stopped but did not push any code. "
if [ -n "$has_changes" ]; then if [ -n "$has_changes" ]; then
nudge+="You have uncommitted changes. Commit them and push." # Nudge: there are uncommitted changes
else local nudge="You stopped but did not push any code. You have uncommitted changes. Commit them and push."
nudge+="Complete the implementation, commit, and push your branch." log "agent_run: nudging (uncommitted changes)"
fi
log "agent_run: nudging (no push detected)"
output=$(cd "$run_dir" && timeout "${CLAUDE_TIMEOUT:-7200}" claude -p "$nudge" --resume "$_AGENT_SESSION_ID" --output-format json --dangerously-skip-permissions --max-turns 50 ${CLAUDE_MODEL:+--model "$CLAUDE_MODEL"} 2>>"$LOGFILE") || true output=$(cd "$run_dir" && timeout "${CLAUDE_TIMEOUT:-7200}" claude -p "$nudge" --resume "$_AGENT_SESSION_ID" --output-format json --dangerously-skip-permissions --max-turns 50 ${CLAUDE_MODEL:+--model "$CLAUDE_MODEL"} 2>>"$LOGFILE") || true
new_sid=$(printf '%s' "$output" | jq -r '.session_id // empty' 2>/dev/null) || true new_sid=$(printf '%s' "$output" | jq -r '.session_id // empty' 2>/dev/null) || true
if [ -n "$new_sid" ]; then if [ -n "$new_sid" ]; then
@ -87,6 +84,9 @@ agent_run() {
fi fi
printf '%s' "$output" > "$diag_file" 2>/dev/null || true printf '%s' "$output" > "$diag_file" 2>/dev/null || true
_AGENT_LAST_OUTPUT="$output" _AGENT_LAST_OUTPUT="$output"
else
log "agent_run: no push and no changes — skipping nudge"
fi
fi fi
fi fi
} }