Skip to content

Commit 0069e8d

Browse files
nohwndCopilot
andauthored
Fix triage agent creating duplicate PRs for the same issue (#15787)
Add mandatory Step 4a: before implementing a fix, search for existing open PRs (by branch name, title/body reference, and cache-memory). If one exists, skip instead of creating another. After creating a PR, add State: In-PR label to the issue so future scheduled runs skip it (the skip list already includes this label). Also tighten backlog selection to exclude issues with State: In-PR. Fixes the pattern where #15643 got 4 separate fix PRs because the agent kept picking it up on scheduled runs without checking for existing work. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 039b7ea commit 0069e8d

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/issue-repro-triage.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Your goal: **drive open issues to zero.** Process the backlog systematically:
107107
2. **New issues from external contributors**: Check issues opened in the last 24 hours that have NOT been triaged yet (no agent comment, no triage labels). These were skipped on creation because the author lacked write permission. Triage them now — they deserve the same treatment as maintainer-filed issues.
108108
3. **Backlog**: Work through open bug issues. Process **up to 3 issues** per run. Selection priority:
109109
a. Issues with `Needs: Triage :mag:` label (untriaged, newest first)
110-
b. Oldest open bug issues that have repro steps but no linked PR
110+
b. Oldest open bug issues that have repro steps but no linked PR and no `State: In-PR` label
111111
c. Issues without repro steps that you can investigate from the description alone
112112
4. **Skip**: issues labeled `State: Blocked`, `Needs: Design`, `State: Approved`, or `State: In-PR`
113113
5. **Skip**: issues you already commented on in the last 7 days (don't re-triage the same issue)
@@ -160,6 +160,24 @@ Check whether the issue contains actionable information:
160160

161161
If the bug is reproducible and the fix appears scoped (not requiring architectural decisions):
162162

163+
#### Step 4a: Check for existing PRs (MANDATORY)
164+
165+
Before writing any code, search for existing open PRs that already address this issue:
166+
167+
1. Search for open PRs with branch names matching `fix/issue-<number>` (e.g. `fix/issue-15643`)
168+
2. Search for open PRs whose title or body references this issue number
169+
3. Check the `auto-fix-prs` cache-memory key for previously created PRs for this issue
170+
171+
**If an existing open PR is found:**
172+
- Do NOT create a new PR. Instead, add a comment on the issue noting the existing PR (if not already noted).
173+
- Add label `State: In-PR` to the issue if not already present.
174+
- If the existing PR has review feedback that hasn't been addressed, consider iterating on it instead of creating a new one — but only if you can push to the branch.
175+
- `noop` with message: "Existing PR #NNN already addresses this issue."
176+
177+
**If all existing PRs for this issue are closed** (not merged), evaluate whether the previous approach was wrong or just abandoned. If wrong, try a different approach. If abandoned, consider reopening rather than creating yet another PR.
178+
179+
#### Step 4b: Implement the fix
180+
163181
1. **Read AGENTS.md** for repo conventions
164182
2. **Understand the root cause** by reading the relevant source code
165183
3. **Implement a fix** on a new branch `fix/issue-<number>`
@@ -174,7 +192,10 @@ The PR description should include:
174192
- What the fix does
175193
- Test that verifies the fix
176194

177-
After creating the PR, **register it in cache-memory** so the PR Iteration workflow knows to follow up:
195+
After creating the PR:
196+
197+
1. **Add label `State: In-PR`** to the issue so future triage runs skip it.
198+
2. **Register it in cache-memory** so the PR Iteration workflow knows to follow up:
178199

179200
```json
180201
// Read existing cache first, then update

0 commit comments

Comments
 (0)