-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Enhanced PR Rescue Workflow
Problem
Agent PRs can get stuck at multiple stages of the pipeline. Current rescue only handles "behind main." Need to unstick PRs at any stage, prioritize ones closest to merging, and run regularly.
Triggers
push: branches: [main]— fires when a PR merges, immediately rescues othersschedule: cron: '*/15 * * * *'— catches anything stuck between mergesworkflow_dispatch— manual trigger
Scope
Only processes aw-labeled PRs with auto-merge enabled. PRs without auto-merge or without the aw label are ignored.
Processing Order
Process PRs closest to merging first. For each PR:
Check 1: No Copilot review
- Condition: Zero reviews from
copilot-pull-request-reviewer - Action:
gh pr edit --add-reviewer @copilot - Then: Stop processing this PR. Let Copilot review, quality-gate, approval flow run. Next rescue cycle picks it up if stuck again.
Check 2: Unresolved threads
- Condition: Has unresolved review threads
- Action:
- Query real thread IDs via
gh api graphql(not hallucinated) - For each unresolved thread, check:
- Has a reply from
github-actions[bot](responder addressed it) - AND
isOutdated: true(referenced code changed, fix was applied)
- Has a reply from
- If both: resolve the thread
- If not: leave it (not addressed, needs human attention)
- Query real thread IDs via
- Then: If any threads still unresolved after this pass, stop processing this PR. Otherwise continue.
Check 3: Behind main
- Condition: Approved + all threads resolved + merge state is BEHIND
- Action:
- Rebase onto latest main
- Push (force-with-lease)
- Remove
review-response-attemptedlabel so responder can run again on any new Copilot comments from the re-review
- Then: CI reruns, approval survives (dismiss_stale_reviews: false), auto-merge fires.
Error Handling
- Each PR is independent — one failure doesn't abort the loop
- git fetch, git checkout, git push wrapped in error guards
- git rebase --abort guarded with || true
- cancel-in-progress: false — don't kill mid-rebase
Edge Cases
- Copilot doesn't review after request: Harmless. Next rescue cycle will see it's still missing and skip (already requested, Copilot is in requested reviewers).
- Thread resolved but not outdated: Not safe to auto-resolve. Could be a reply saying "I disagree" without a code change. Leave it.
- Rescue runs while responder is in progress: Resolve calls succeed or fail harmlessly. Responder's later resolve fails (already resolved). No conflict.
- New Copilot comments after rebase: review-response-attempted label removed, so responder runs again. If responder hallucinates IDs again, next rescue cycle resolves them.
No Permission Changes Needed
All API calls use GH_AW_WRITE_TOKEN which already has write access.
Related
- tracking: upgrade gh-aw MCP server to get real thread IDs for review-responder #114 — Thread ID hallucination root cause
- workaround: give review-responder bash tool for gh api graphql thread ID lookup #117 — Bash tool workaround for responder (complementary)
- Upgrade pinned github-mcp-server from v0.32.0 to v0.33.0+ to fix thread resolution github/gh-aw#21130 — Upstream MCP server upgrade (permanent fix for thread IDs)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels