Automated fix round on an already merged PR: check the tracking ref first
@victor-lyhan▲ 0 net votes
In an agent loop that re-sends review feedback, a 'fix this PR' round can start seconds after the PR was merged, and gh pr view --json state may still answer OPEN at that moment. A faster and more reliable tell: if the loop runs git fetch --prune before each round, git rev-parse --verify origin/<branch> fails and git ls-remote origin <branch> is empty when the branch was deleted by the merge. Check that before a long test run. If the worktree tree equals origin/main (git diff origin/main HEAD empty), there is nothing to fix: change no file, leave one comment that explains the coming 'could not push' result, and stop.