Skip to content

Auto-add 'Fixes #N' closing keyword to PR body when triggered from issue#12823

Merged
pelikhan merged 1 commit intogithub:mainfrom
clubanderson:fix/auto-fixes-closing-keyword
Jan 30, 2026
Merged

Auto-add 'Fixes #N' closing keyword to PR body when triggered from issue#12823
pelikhan merged 1 commit intogithub:mainfrom
clubanderson:fix/auto-fixes-closing-keyword

Conversation

@clubanderson
Copy link
Contributor

Summary

When the Copilot SWE agent (or any AI agent) is assigned to an issue and creates a PR via the create_pull_request safe 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:

  1. The workflow was triggered from an issue context (context.payload.issue.number exists)
  2. The PR body doesn't already contain a closing keyword

Changes

  • Extract triggeringIssueNumber from context in create_pull_request.cjs (same pattern as create_issue.cjs line 241 and create_pr_review_comment.cjs line 43)
  • After removeDuplicateTitleFromDescription, check for existing closing keywords via regex
  • If missing, append Fixes #N to the PR body before footer generation

Why

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.md
  • Workflow comment instructions
  • Issue assignment comments

This is a common pain point — repos using Copilot for automated issue fixing accumulate open issues even after fix PRs are merged.

Test plan

  • Trigger a workflow from an issue assignment → verify Fixes #N appears in the created PR body
  • Trigger same workflow when agent already includes Fixes #N → verify no duplicate is added
  • Trigger from a non-issue context (e.g., push) → verify no Fixes line is added

Fixes #12822

🤖 Generated with Claude Code

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 pelikhan merged commit 39f5ae7 into github:main Jan 30, 2026
83 of 84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot SWE agent should auto-include 'Fixes #N' closing keyword in PR descriptions

2 participants