Skip to content

Suggest possible duplicate issues without automatically closing them - #202981

Closed
drisspg wants to merge 5 commits into
gh/drisspg/470/basefrom
gh/drisspg/470/head
Closed

drisspg wants to merge 5 commits into
gh/drisspg/470/basefrom
gh/drisspg/470/head

Conversation

@drisspg

@drisspg drisspg commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Human Note

Let agents suggest duplicate issues

Agent Notes

Why

Finding a likely duplicate should help the reporter, not silently discard their report. Add a
suggestion-only path for ordinary issues: explain the possible match, ask the reporter to check it,
and leave the final decision to them. This is separate from approved umbrella closure policies.

What happens

After reading a candidate's body and relevant comments, the model can propose
possible_duplicate: <issue number>. The trusted apply step validates the reference and posts fixed
copy linking that issue. It keeps the source open and never writes to the candidate, which may
already be open or closed.

flowchart TD
    M["Model reads candidate and proposes possible_duplicate"] --> V{"Source, target and plan are eligible?"}
    V -->|No| R["No duplicate suggestion; skip or flag review"]
    V -->|Yes| B{"Matching bot suggestion already posted?"}
    B -->|Yes| N["Do not repeat the comment"]
    B -->|No| C["Post fixed linked suggestion"]
    N --> O["Keep source open; finish any pending labels"]
    C --> O
    O --> H["Reporter can confirm the match or explain the difference"]
Loading
Scenario Outcome
Plausible same underlying bug, with candidate context read Suggest the linked issue and ask the reporter to confirm. No automatic closure.
Similar operator/title, or a report that still reproduces after the candidate's fix Do not infer a duplicate; keep investigating the new report.
Self-reference, foreign/PR/unavailable target, catalog umbrella, or conflicting close/umbrella annotation No ordinary duplicate suggestion; skip or route to review.
Retry after comment succeeded but label writing failed Do not repost; finish the pending labels.

The comment asks reporters to move any new reproduction details to the linked issue and close
their own issue only if it is the same problem. Otherwise they can explain what differs. The
model supplies neither a URL nor free-form comment text; same-repository links and the wording are
constructed by trusted code. Semantic matching still depends on the model and human judgment.

Test Plan

PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts/issue_triage_pi -v
git diff --check

106 Python tests pass, including 11 new suggestion tests. The initial comment test and a closed-source skip-fallback regression failed before their fixes and pass afterward.

Current PyTorch PR test job. The Python suite also runs in triage preparation, before the model.

Validation

Before test consolidation, pinned-runtime ciforge CI passed 119 Python tests and 4 search-tool tests with Pi 0.99.1.

Read-only ciforge replay searched and read #200935's body/comments, then proposed it as a possible duplicate of #202764 with no automatic closure. The related-only case stayed open, and the two umbrella controls retained their close/link proposals. Apply was skipped; no comments or issue changes were posted.

The positive candidate's comments explicitly confirmed the duplicate relationship, so this is current-context integration evidence, not a blind accuracy benchmark. The related-only case had empty search results. Real-write behavior for this new suggestion path has not been exercised in ciforge; source-only writes and retries are covered by the local tests.

Linked issue or supporting maintainer

Triage-tooling follow-up; #202764 and #200935 were used as a confirmed duplicate replay case.

BC-breaking?

No public PyTorch API change.

Summary (human written only)

Agent details (if applicable)

AI-assisted implementation and validation are described in Agent Notes above.

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

PR Status: in progress

A maintainer requested changes. Please address their feedback before the PR returns to maintainer review.

To become ready for review, the change must pass automated review and every maintainer comment must be addressed, either with a code change or a reply explaining why no change is needed. A fresh automated review checks that the feedback has been addressed. All CI must finish and Dr. CI must classify every failure as unrelated to your PR. Fix the failures it attributes to your PR (see status below in this comment). Workflows waiting for a maintainer to approve their run do not block this.

To minimize iteration time, feel free to run the pr-review skill from the repo locally. If you address comments without pushing, comment @pytorchbot review to re-run the automated review. To bypass automated review, please add the “no automated review” label.

🟡 AUTOMATED REVIEW - Changes requested:

This PR adds an optional `possible_duplicate` field to the issue-triage plan;
the trusted apply step then posts a fixed comment on the source issue suggesting
the linked issue, and the source stays open. Recommendation: Request Changes.
The bot can send a reporter to a dead, locked or attacker-chosen target,
decision handling differs from the umbrella path, and a source closed before
apply fails the job without the tests noticing; the three blocking findings from
the earlier automated review are still unaddressed at HEAD.

Findings (11):

[major] scripts/issue_triage_pi/apply_plan.py:230
Security: nothing trusted limits which issue the target can be. The model picks
the target after reading untrusted issue bodies and comments, and apply accepts
any open or closed same-repo issue that isn't in the catalog. It never checks
`created_at` against the source, `locked`, or the target author's
`author_association`. Attack: someone files a look-alike issue whose text steers
the model, and the bot then tells a real reporter, with its own authority, to
move their repro details there and close theirs. The attacker controls that
thread and can edit it later, and download-link redaction only applies to the
source body. The umbrella path is safe because its targets must be in the
checked-in `umbrellas.json`. The PR's argument that "the model supplies neither
a URL nor free-form comment text" doesn't cover this. Fix: at minimum, require
the target to predate the source and be unlocked. Consider also requiring a
maintainer-associated author or existing triage labels on the target. Document
the remaining risk in `.github/actions/pi-agent/README.md:127-131`.

[major] scripts/issue_triage_pi/apply_plan.py:237
The target-state check never rejects anything, and the fixed wording is wrong
for most targets. GitHub only returns `open`/`closed`, so `target.get("state")
not in ("open", "closed")` does nothing, and `state_reason`/`locked` are never
read. The model can't avoid bad targets either, because
`get_issue`/`search_issues` in `github-issue-tools.ts:83-93,147-152` don't
expose them, so SKILL.md:112 can't be followed reliably. Every target gets "add
any new reproduction details there and close this issue  still reproduces after
the linked issue's fix". For a `not_planned`/`duplicate` target, the reporter is
asked to close their only live report for a thread nobody watches, the very
"silently discard" outcome the PR says it avoids. A locked target can't take new
details, and an open target has no fix yet. `umbrella_comment` requires `state
== "open"` (:330). Fix: reject `not_planned`, `duplicate` and locked targets,
and choose the wording by target state. For a target closed as `completed`, ask
the reporter to confirm on their own issue rather than close it. Also replace ``
and `` with ASCII to match `templates.json`.

[major] scripts/issue_triage_pi/apply_plan.py:225
Decisions other than `label`/`triage_review` are handled differently from the
umbrella path (:317-322, 342-353). With `redirect_oncall`, the plan is rejected
and `triage review` is added (:501-502), so the issue gets both `oncall: X` and
`triage review` and sits in two queues, while the umbrella path skips quietly. A
`decision: "label"` plan with a non-pt2 oncall label (e.g. `oncall:
distributed`) passes the check, because `possible_duplicate_comment` never
receives the label set, so the suggestion is posted on an issue being routed to
another team. `request_info`/`request_reproduction` are escalated to review,
while the umbrella path posts a link only. None of this escalation is documented
in the schema description (`issue-triage-plan.json:53`), SKILL.md:62 or
README:127-131. Fix: apply the umbrella's oncall rule (skip quietly on
`redirect_oncall` or any non-pt2 `oncall:` label), and either allow the
suggestion on info/reproduction requests or document the escalation.

(8 more not shown, see the review run)

Reviewed commit: f03a181

Review run

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/202981

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit f03a181 with merge base 78def3c (image):
💚 Looks good so far! There are no failures yet. 💚

🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:

  • Triviality
    • New feature: possible_duplicate lets the triage model trigger a bot comment on issues via possible_duplicate_comment in scripts/issue_triage_pi/apply_plan.py
    • Fits no trivial class; a reviewer would plausibly question the user-facing comment wording and the duplicate heuristics
  • Trust boundary
    • The model reads untrusted issue text and its plan now drives a new write path in the issues: write apply step
    • Changes the model's steering in .github/workflows/issue-triage-pi.yml and .agents/skills/triaging-issues/SKILL.md
  • Behavior change beyond the feature
    • The open-source-issue check in plan_effects now runs before the skip_already_routed branch, which changes umbrella plans that take that branch
  • Socialization
    • Adds new bot-posted copy asking reporters to close their own issues, which triage maintainers should know about

reason: not_trivial
Reviewed commit: 3e957d8 (NOT the current head f03a181)

Inference job

🐛 Report a wrong verdict

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]
drisspg added a commit that referenced this pull request Nov 2, 2026
## Human Note

Let agents suggest duplicate issues

## Agent Notes

Let triage propose an ordinary same-repository issue as a possible duplicate after reading its body and relevant comments. The trusted apply step posts a fixed link asking the reporter to confirm the match and close their own issue only if appropriate. The bot keeps the source issue open and never writes to the candidate.

The plan supplies an issue number, not a URL or comment. Source and target are validated again before writes; invalid targets and conflicting close/umbrella annotations fall back to review. A bot-authored target marker suppresses repeated suggestions on retries. Catalog umbrella link/close rules remain separate.

### Test Plan

```sh
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts/issue_triage_pi -v
git diff --check
```

119 Python tests pass, including 11 new suggestion tests. The initial comment test and a closed-source skip-fallback regression failed before their fixes and pass afterward.

## Validation

[Pinned-runtime ciforge CI](https://github.com/pytorch/ciforge/actions/runs/41379809233) passed 119 Python tests and 4 search-tool tests with Pi 0.99.1.

[Read-only ciforge replay](https://github.com/pytorch/ciforge/actions/runs/41379809226) searched and read #200935's body/comments, then proposed it as a possible duplicate of #202764 with no automatic closure. The related-only case stayed open, and the two umbrella controls retained their close/link proposals. Apply was skipped; no comments or issue changes were posted.

The positive candidate's comments explicitly confirmed the duplicate relationship, so this is current-context integration evidence, not a blind accuracy benchmark. The related-only case had empty search results. Real-write behavior for this new suggestion path has not been exercised in ciforge; source-only writes and retries are covered by the local tests.

## Linked issue or supporting maintainer

Triage-tooling follow-up; #202764 and #200935 were used as a confirmed duplicate replay case.

## BC-breaking?

No public PyTorch API change.

## Summary (human written only)

## Agent details (if applicable)

AI-assisted implementation and validation are described in Agent Notes above.


ghstack-source-id: 157ed1b
Pull-Request: #202981
@drisspg
drisspg marked this pull request as ready for review November 2, 2026 17:24
@drisspg
drisspg requested a review from a team as a code owner November 2, 2026 17:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T17:26:07.645833Z 3e957d8 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pytorchgreenlight pytorchgreenlight Bot added the GL/human GreenLight marked as needing human review label Nov 2, 2026
@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Nov 2, 2026
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
drisspg added a commit that referenced this pull request Nov 2, 2026
## Human Note

Let agents suggest duplicate issues

## Agent Notes

Let triage propose an ordinary same-repository issue as a possible duplicate after reading its body and relevant comments. The trusted apply step posts a fixed link asking the reporter to confirm the match and close their own issue only if appropriate. The bot keeps the source issue open and never writes to the candidate.

The plan supplies an issue number, not a URL or comment. Source and target are validated again before writes; invalid targets and conflicting close/umbrella annotations fall back to review. A bot-authored target marker suppresses repeated suggestions on retries. Catalog umbrella link/close rules remain separate.

### Test Plan

```sh
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts/issue_triage_pi -v
git diff --check
```

119 Python tests pass, including 11 new suggestion tests. The initial comment test and a closed-source skip-fallback regression failed before their fixes and pass afterward.

## Validation

[Pinned-runtime ciforge CI](https://github.com/pytorch/ciforge/actions/runs/41379809233) passed 119 Python tests and 4 search-tool tests with Pi 0.99.1.

[Read-only ciforge replay](https://github.com/pytorch/ciforge/actions/runs/41379809226) searched and read #200935's body/comments, then proposed it as a possible duplicate of #202764 with no automatic closure. The related-only case stayed open, and the two umbrella controls retained their close/link proposals. Apply was skipped; no comments or issue changes were posted.

The positive candidate's comments explicitly confirmed the duplicate relationship, so this is current-context integration evidence, not a blind accuracy benchmark. The related-only case had empty search results. Real-write behavior for this new suggestion path has not been exercised in ciforge; source-only writes and retries are covered by the local tests.

## Linked issue or supporting maintainer

Triage-tooling follow-up; #202764 and #200935 were used as a confirmed duplicate replay case.

## BC-breaking?

No public PyTorch API change.

## Summary (human written only)

## Agent details (if applicable)

AI-assisted implementation and validation are described in Agent Notes above.


ghstack-source-id: 247bfb4
Pull-Request: #202981
@pytorchgreenlight pytorchgreenlight Bot added GL/superseded GreenLight review is superseded by changes and removed GL/human GreenLight marked as needing human review labels Nov 2, 2026
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
drisspg added a commit that referenced this pull request Nov 2, 2026
## Human Note

Let agents suggest duplicate issues

## Agent Notes

Let triage propose an ordinary same-repository issue as a possible duplicate after reading its body and relevant comments. The trusted apply step posts a fixed link asking the reporter to confirm the match and close their own issue only if appropriate. The bot keeps the source issue open and never writes to the candidate.

The plan supplies an issue number, not a URL or comment. Source and target are validated again before writes; invalid targets and conflicting close/umbrella annotations fall back to review. A bot-authored target marker suppresses repeated suggestions on retries. Catalog umbrella link/close rules remain separate.

### Test Plan

```sh
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts/issue_triage_pi -v
git diff --check
```

119 Python tests pass, including 11 new suggestion tests. The initial comment test and a closed-source skip-fallback regression failed before their fixes and pass afterward.

## Validation

[Pinned-runtime ciforge CI](https://github.com/pytorch/ciforge/actions/runs/41379809233) passed 119 Python tests and 4 search-tool tests with Pi 0.99.1.

[Read-only ciforge replay](https://github.com/pytorch/ciforge/actions/runs/41379809226) searched and read #200935's body/comments, then proposed it as a possible duplicate of #202764 with no automatic closure. The related-only case stayed open, and the two umbrella controls retained their close/link proposals. Apply was skipped; no comments or issue changes were posted.

The positive candidate's comments explicitly confirmed the duplicate relationship, so this is current-context integration evidence, not a blind accuracy benchmark. The related-only case had empty search results. Real-write behavior for this new suggestion path has not been exercised in ciforge; source-only writes and retries are covered by the local tests.

## Linked issue or supporting maintainer

Triage-tooling follow-up; #202764 and #200935 were used as a confirmed duplicate replay case.

## BC-breaking?

No public PyTorch API change.

## Summary (human written only)

## Agent details (if applicable)

AI-assisted implementation and validation are described in Agent Notes above.


ghstack-source-id: 7729c35
Pull-Request: #202981
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
drisspg added a commit that referenced this pull request Nov 3, 2026
## Human Note

Let agents suggest duplicate issues

## Agent Notes

Let triage propose an ordinary same-repository issue as a possible duplicate after reading its body and relevant comments. The trusted apply step posts a fixed link asking the reporter to confirm the match and close their own issue only if appropriate. The bot keeps the source issue open and never writes to the candidate.

The plan supplies an issue number, not a URL or comment. Source and target are validated again before writes; invalid targets and conflicting close/umbrella annotations fall back to review. A bot-authored target marker suppresses repeated suggestions on retries. Catalog umbrella link/close rules remain separate.

### Test Plan

```sh
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts/issue_triage_pi -v
git diff --check
```

119 Python tests pass, including 11 new suggestion tests. The initial comment test and a closed-source skip-fallback regression failed before their fixes and pass afterward.

## Validation

[Pinned-runtime ciforge CI](https://github.com/pytorch/ciforge/actions/runs/41379809233) passed 119 Python tests and 4 search-tool tests with Pi 0.99.1.

[Read-only ciforge replay](https://github.com/pytorch/ciforge/actions/runs/41379809226) searched and read #200935's body/comments, then proposed it as a possible duplicate of #202764 with no automatic closure. The related-only case stayed open, and the two umbrella controls retained their close/link proposals. Apply was skipped; no comments or issue changes were posted.

The positive candidate's comments explicitly confirmed the duplicate relationship, so this is current-context integration evidence, not a blind accuracy benchmark. The related-only case had empty search results. Real-write behavior for this new suggestion path has not been exercised in ciforge; source-only writes and retries are covered by the local tests.

## Linked issue or supporting maintainer

Triage-tooling follow-up; #202764 and #200935 were used as a confirmed duplicate replay case.

## BC-breaking?

No public PyTorch API change.

## Summary (human written only)

## Agent details (if applicable)

AI-assisted implementation and validation are described in Agent Notes above.


ghstack-source-id: e9b76fa
Pull-Request: #202981

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review of f03a181: changes requested before human review.

This PR adds an optional possible_duplicate field to the issue-triage plan; the trusted apply step then posts a fixed comment on the source issue suggesting the linked issue, and the source stays open. Recommendation: Request Changes. The bot can send a reporter to a dead, locked or attacker-chosen target, decision handling differs from the umbrella path, and a source closed before apply fails the job without the tests noticing; the three blocking findings from the earlier automated review are still unaddressed at HEAD.

🔴 5 blocking findings are attached to the code below.

⚪ 6 non-blocking findings

if ("umbrella" in plan or "possible_duplicate" in plan) and (

Backward compatibility: moving the source-open check changes existing umbrella plans. The related-issue source check now runs before the skip_already_routed branch; the old umbrella check ran after it. Before, an umbrella + skip_already_routed plan on a PR or foreign source got triage review and bot-triaged. Now it gets no writes, the outcome is no_action, and main() exits 1. On a closed source it also gets no writes, with outcome closed. The change may be intended, but the PR description doesn't mention it and no test in test_umbrella_plan.py covers it. Add an umbrella case and note the change in the description.


effects.possible_duplicate = number

A rejected target leaves no trace in the step summary. effects.possible_duplicate is only set on success, and neither rejection note (:226-228, :240-242) names the proposed number. The umbrella path records umbrella_issue before validating and always prints **Umbrella:** **Target:** (:313-316, 731-737). Record the proposed number, or print a **Possible duplicate:** #N (rejected) line.


type(number) is not int

Redundant validation and duplicated fetch helpers. The number checks at :231-233 repeat fetch_possible_duplicate (:208) and can't be reached through main() or current_reference_effects, because target is already None and :234 rejects first. fetch_possible_duplicate (:206-213) is also a near copy of fetch_umbrella_target (:190-203). Drop the duplicate checks and share one fetch_related_issue(repo, number) helper.


return json.dumps([self.comments])

The fake API is weaker than the umbrella fake. Paginated and non-paginated comment reads both return every comment as one page, so dropping all_comments=True at apply_plan.py:622 or :774 would fail no test; test_umbrella_plan.py:64-67 splits comments across pages to catch this. Target reads also ignore the retry kwarg, so the retry=False at apply_plan.py:211 is untested; the umbrella fake rejects retry=True (test_umbrella_plan.py:71-74).


self.assertEqual(len(api.writes), 2)

Missing coverage, and assertions that can't fail. The success test only checks len(api.writes) == 2, never which labels are added; triaged is added (apply_plan.py:551-559) while the bot asks the reporter to confirm, and nothing pins that down either way. Nothing covers triage_review with a valid target, redirect_oncall, request_info, request_reproduction, or label with a non-pt2 oncall label. No test sets state_reason or locked, and the issue() helper can't produce them; the state="unknown" subcase uses a value GitHub never returns. test_closed_candidate_can_be_suggested_without_mutating_it asserts the disputed behaviour as correct. In test_invalid_or_catalog_targets_never_get_duplicate_suggestions, five of the seven values are rejected in fetch_possible_duplicate and never reach a target read, so only the two catalog numbers test target validation. Assertions on api.target\["state"\] and api.source\["state"\] == "closed" can never fail: the fake never changes the target and closes the source on its own.


"possible_duplicate": {

PlanSchemaTest (test_apply_plan.py:300-315) doesn't cover the new field. The schema sets additionalProperties: false, and the new tests write plan JSON without validating it, so renaming possible_duplicate on either side would silently disable the feature. (umbrella was never covered either, so this gap predates the PR.) Assert the schema's possible_duplicate entry (integer, minimum 1) in PlanSchemaTest.

Please address the findings and push; a new commit normally gets a fresh automated review.

This review is AI-generated and advisory. Each new automated review replaces the previous one.

"possible duplicate conflicts with the decision; kept open for review"
)
return "", False
if (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Security: nothing trusted limits which issue the target can be. The model picks the target after reading untrusted issue bodies and comments, and apply accepts any open or closed same-repo issue that isn't in the catalog. It never checks created_at against the source, locked, or the target author's author_association. Attack: someone files a look-alike issue whose text steers the model, and the bot then tells a real reporter, with its own authority, to move their repro details there and close theirs. The attacker controls that thread and can edit it later, and download-link redaction only applies to the source body. The umbrella path is safe because its targets must be in the checked-in umbrellas.json. The PR's argument that "the model supplies neither a URL nor free-form comment text" doesn't cover this. Fix: at minimum, require the target to predate the source and be unlocked. Consider also requiring a maintainer-associated author or existing triage labels on the target. Document the remaining risk in .github/actions/pi-agent/README.md:127-131.

or not isinstance(target, dict)
or type(target.get("number")) is not int
or not is_repo_issue(target, repo, number)
or target.get("state") not in ("open", "closed")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 The target-state check never rejects anything, and the fixed wording is wrong for most targets. GitHub only returns open/closed, so target.get("state") not in ("open", "closed") does nothing, and state_reason/locked are never read. The model can't avoid bad targets either, because get_issue/search_issues in github-issue-tools.ts:83-93,147-152 don't expose them, so SKILL.md:112 can't be followed reliably. Every target gets "add any new reproduction details there and close this issue still reproduces after the linked issue's fix". For a not_planned/duplicate target, the reporter is asked to close their only live report for a thread nobody watches, the very "silently discard" outcome the PR says it avoids. A locked target can't take new details, and an open target has no fix yet. umbrella_comment requires state == "open" (:330). Fix: reject not_planned, duplicate and locked targets, and choose the wording by target state. For a target closed as completed, ask the reporter to confirm on their own issue rather than close it. Also replace and with ASCII to match templates.json.

effects: Effects,
) -> tuple[str, bool]:
number = plan["possible_duplicate"]
if "umbrella" in plan or plan["decision"] not in ("label", "triage_review"):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Decisions other than label/triage_review are handled differently from the umbrella path (:317-322, 342-353). With redirect_oncall, the plan is rejected and triage review is added (:501-502), so the issue gets both oncall: X and triage review and sits in two queues, while the umbrella path skips quietly. A decision: "label" plan with a non-pt2 oncall label (e.g. oncall: distributed) passes the check, because possible_duplicate_comment never receives the label set, so the suggestion is posted on an issue being routed to another team. request_info/request_reproduction are escalated to review, while the umbrella path posts a link only. None of this escalation is documented in the schema description (issue-triage-plan.json:53), SKILL.md:62 or README:127-131. Fix: apply the umbrella's oncall rule (skip quietly on redirect_oncall or any non-pt2 oncall: label), and either allow the suggestion on info/reproduction requests or document the escalation.

issue=args.issue,
source={**issue, "state": "open"} if args.replay else issue,
umbrella_target=fetch_umbrella_target(args.repo, args.issue, plan),
duplicate_target=fetch_possible_duplicate(args.repo, args.issue, plan),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 A source closed before apply fails the job. current_reference_effects sees the closed source and returns empty effects, but state_after (:808-810) still uses the stale "open" state from main()'s first read. The outcome is then no_action and main() returns 1 (:824-826). The apply step (issue-triage-pi.yml:209-213) runs under the default bash -e with no || rc, so the job fails and the distributed hand-off at :216-222 is skipped. Non-skip umbrella plans already had this race; this PR extends it to possible_duplicate and to skip + related-issue plans. test_skip_fallback_does_not_mutate_a_source_closed_before_apply exercises exactly this case and passes only because the test ignores the return value. Fix: take state_after from the rechecked source.

patch("apply_plan.publish") as publish,
patch("sys.stdout", new_callable=StringIO),
):
apply_plan.main()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 run_plan ignores main()'s return value, while test_umbrella_plan.py:152 asserts apply_plan.main() == 0. Three runs end in no_action, which exits 1 and would fail the workflow, yet the tests pass: the PR-source and foreign-source subcases of test_source_and_target_are_revalidated_before_writes, and test_skip_fallback_does_not_mutate_a_source_closed_before_apply. Assert the exit code.

@drisspg

drisspg commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -f

@pytorch-bot

pytorch-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

❌ 🤖 pytorchbot command failed:

@pytorchbot merge: error: argument -f/--force: expected one argument

usage: @pytorchbot merge [-f MESSAGE | -i] [-ic] [-r [{viable/strict,main}]]

Try @pytorchbot --help for more info.

@drisspg

drisspg commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -f "Bypass advisory automated reviews; human reviewers approved the stack"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
…ytorch#202981)

## Human Note

Let agents suggest duplicate issues

## Agent Notes

### Why

Finding a likely duplicate should help the reporter, not silently discard their report. Add a
suggestion-only path for ordinary issues: explain the possible match, ask the reporter to check it,
and leave the final decision to them. This is separate from approved umbrella closure policies.

### What happens

After reading a candidate's body and relevant comments, the model can propose
`possible_duplicate: <issue number>`. The trusted apply step validates the reference and posts fixed
copy linking that issue. It keeps the source open and never writes to the candidate, which may
already be open or closed.

```mermaid
flowchart TD
    M["Model reads candidate and proposes possible_duplicate"] --> V{"Source, target and plan are eligible?"}
    V -->|No| R["No duplicate suggestion; skip or flag review"]
    V -->|Yes| B{"Matching bot suggestion already posted?"}
    B -->|Yes| N["Do not repeat the comment"]
    B -->|No| C["Post fixed linked suggestion"]
    N --> O["Keep source open; finish any pending labels"]
    C --> O
    O --> H["Reporter can confirm the match or explain the difference"]
```

| Scenario | Outcome |
| --- | --- |
| Plausible same underlying bug, with candidate context read | Suggest the linked issue and ask the reporter to confirm. No automatic closure. |
| Similar operator/title, or a report that still reproduces after the candidate's fix | Do not infer a duplicate; keep investigating the new report. |
| Self-reference, foreign/PR/unavailable target, catalog umbrella, or conflicting close/umbrella annotation | No ordinary duplicate suggestion; skip or route to review. |
| Retry after comment succeeded but label writing failed | Do not repost; finish the pending labels. |

The comment asks reporters to move any new reproduction details to the linked issue and close
their own issue **only if it is the same problem**. Otherwise they can explain what differs. The
model supplies neither a URL nor free-form comment text; same-repository links and the wording are
constructed by trusted code. Semantic matching still depends on the model and human judgment.

### Test Plan

```sh
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts/issue_triage_pi -v
git diff --check
```

106 Python tests pass, including 11 new suggestion tests. The initial comment test and a closed-source skip-fallback regression failed before their fixes and pass afterward.

[Current PyTorch PR test job](https://github.com/pytorch/pytorch/actions/runs/41384204576/job/125081314456). The Python suite also runs in triage preparation, before the model.

## Validation

Before test consolidation, [pinned-runtime ciforge CI](https://github.com/pytorch/ciforge/actions/runs/41379809233) passed 119 Python tests and 4 search-tool tests with Pi 0.99.1.

[Read-only ciforge replay](https://github.com/pytorch/ciforge/actions/runs/41379809226) searched and read pytorch#200935's body/comments, then proposed it as a possible duplicate of pytorch#202764 with no automatic closure. The related-only case stayed open, and the two umbrella controls retained their close/link proposals. Apply was skipped; no comments or issue changes were posted.

The positive candidate's comments explicitly confirmed the duplicate relationship, so this is current-context integration evidence, not a blind accuracy benchmark. The related-only case had empty search results. Real-write behavior for this new suggestion path has not been exercised in ciforge; source-only writes and retries are covered by the local tests.

## Linked issue or supporting maintainer

Triage-tooling follow-up; pytorch#202764 and pytorch#200935 were used as a confirmed duplicate replay case.

## BC-breaking?

No public PyTorch API change.

## Summary (human written only)

## Agent details (if applicable)

AI-assisted implementation and validation are described in Agent Notes above.

Pull Request resolved: pytorch#202981
Approved by: https://github.com/ezyang, https://github.com/malfet
ghstack dependencies: pytorch#203124, pytorch#202961, pytorch#202962
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
…ytorch#202981)

## Human Note

Let agents suggest duplicate issues

## Agent Notes

### Why

Finding a likely duplicate should help the reporter, not silently discard their report. Add a
suggestion-only path for ordinary issues: explain the possible match, ask the reporter to check it,
and leave the final decision to them. This is separate from approved umbrella closure policies.

### What happens

After reading a candidate's body and relevant comments, the model can propose
`possible_duplicate: <issue number>`. The trusted apply step validates the reference and posts fixed
copy linking that issue. It keeps the source open and never writes to the candidate, which may
already be open or closed.

```mermaid
flowchart TD
    M["Model reads candidate and proposes possible_duplicate"] --> V{"Source, target and plan are eligible?"}
    V -->|No| R["No duplicate suggestion; skip or flag review"]
    V -->|Yes| B{"Matching bot suggestion already posted?"}
    B -->|Yes| N["Do not repeat the comment"]
    B -->|No| C["Post fixed linked suggestion"]
    N --> O["Keep source open; finish any pending labels"]
    C --> O
    O --> H["Reporter can confirm the match or explain the difference"]
```

| Scenario | Outcome |
| --- | --- |
| Plausible same underlying bug, with candidate context read | Suggest the linked issue and ask the reporter to confirm. No automatic closure. |
| Similar operator/title, or a report that still reproduces after the candidate's fix | Do not infer a duplicate; keep investigating the new report. |
| Self-reference, foreign/PR/unavailable target, catalog umbrella, or conflicting close/umbrella annotation | No ordinary duplicate suggestion; skip or route to review. |
| Retry after comment succeeded but label writing failed | Do not repost; finish the pending labels. |

The comment asks reporters to move any new reproduction details to the linked issue and close
their own issue **only if it is the same problem**. Otherwise they can explain what differs. The
model supplies neither a URL nor free-form comment text; same-repository links and the wording are
constructed by trusted code. Semantic matching still depends on the model and human judgment.

### Test Plan

```sh
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s scripts/issue_triage_pi -v
git diff --check
```

106 Python tests pass, including 11 new suggestion tests. The initial comment test and a closed-source skip-fallback regression failed before their fixes and pass afterward.

[Current PyTorch PR test job](https://github.com/pytorch/pytorch/actions/runs/41384204576/job/125081314456). The Python suite also runs in triage preparation, before the model.

## Validation

Before test consolidation, [pinned-runtime ciforge CI](https://github.com/pytorch/ciforge/actions/runs/41379809233) passed 119 Python tests and 4 search-tool tests with Pi 0.99.1.

[Read-only ciforge replay](https://github.com/pytorch/ciforge/actions/runs/41379809226) searched and read pytorch#200935's body/comments, then proposed it as a possible duplicate of pytorch#202764 with no automatic closure. The related-only case stayed open, and the two umbrella controls retained their close/link proposals. Apply was skipped; no comments or issue changes were posted.

The positive candidate's comments explicitly confirmed the duplicate relationship, so this is current-context integration evidence, not a blind accuracy benchmark. The related-only case had empty search results. Real-write behavior for this new suggestion path has not been exercised in ciforge; source-only writes and retries are covered by the local tests.

## Linked issue or supporting maintainer

Triage-tooling follow-up; pytorch#202764 and pytorch#200935 were used as a confirmed duplicate replay case.

## BC-breaking?

No public PyTorch API change.

## Summary (human written only)

## Agent details (if applicable)

AI-assisted implementation and validation are described in Agent Notes above.

Pull Request resolved: pytorch#202981
Approved by: https://github.com/ezyang, https://github.com/malfet
ghstack dependencies: pytorch#203124, pytorch#202961, pytorch#202962
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GL/superseded GreenLight review is superseded by changes in progress PR is being worked on by the author, until the automated review accepts it Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants