Auto-add 'Fixes #N' closing keyword to PR body when triggered from issue#12823
Merged
pelikhan merged 1 commit intogithub:mainfrom Jan 30, 2026
Merged
Conversation
When a workflow is triggered by an issue (e.g., Copilot SWE agent assigned to fix an issue), the created PR should include a GitHub closing keyword so the issue auto-closes on merge. Agents are instructed to include "Fixes #N" in PR descriptions, but they don't reliably follow this instruction. This change adds automatic injection of the closing keyword when: 1. The workflow was triggered from an issue context 2. The PR body doesn't already contain a closing keyword (fix/close/resolve) Uses the same `triggeringIssueNumber` pattern already established in `create_issue.cjs` and `create_pr_review_comment.cjs`. Fixes github#12822 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Andrew Anderson <andy@clubanderson.com>
pelikhan
approved these changes
Jan 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the Copilot SWE agent (or any AI agent) is assigned to an issue and creates a PR via the
create_pull_requestsafe output, the PR body typically doesn't include GitHub closing keywords (Fixes #N,Closes #N,Resolves #N). This means the original issue does not auto-close when the PR is merged.This PR auto-injects
Fixes #<issue_number>into the PR body when:context.payload.issue.numberexists)Changes
triggeringIssueNumberfrom context increate_pull_request.cjs(same pattern ascreate_issue.cjsline 241 andcreate_pr_review_comment.cjsline 43)removeDuplicateTitleFromDescription, check for existing closing keywords via regexFixes #Nto the PR body before footer generationWhy
Agents are instructed to include "Fixes #ISSUE_NUMBER" in PR descriptions but don't reliably follow it. Tested across 10+ Copilot PRs in kubestellar/console — none included closing keywords despite the instruction appearing in:
.github/copilot-instructions.mdThis is a common pain point — repos using Copilot for automated issue fixing accumulate open issues even after fix PRs are merged.
Test plan
Fixes #Nappears in the created PR bodyFixes #N→ verify no duplicate is addedpush) → verify noFixesline is addedFixes #12822
🤖 Generated with Claude Code