Skip to content

Update close safe-output types to recommend comments and handle already-closed entities#15489

Merged
pelikhan merged 5 commits intomainfrom
copilot/update-close-issue-output
Feb 13, 2026
Merged

Update close safe-output types to recommend comments and handle already-closed entities#15489
pelikhan merged 5 commits intomainfrom
copilot/update-close-issue-output

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

Modified close_issue, close_pull_request, and close_discussion safe-output types to explicitly recommend adding closing comments and to post comments even when the target entity is already closed.

Changes

Tool descriptions (safe_outputs_tools.json)

  • Added guidance: "You can and should always add a comment when closing [entity] to explain the action or provide context"
  • Documented behavior: "If the [entity] is already closed, a comment will still be posted"

Handler behavior

  • close_issue.cjs, close_pull_request.cjs: Now post comments to already-closed entities, return alreadyClosed: true flag, skip redundant close API call
  • close_discussion.cjs: Added closed field to GraphQL query, posts comments to already-closed discussions
  • close_entity_helpers.cjs: Updated shared logic to comment on already-closed entities instead of skipping

Example behavior

// Before: skipped already-closed entities entirely
if (entity.state === "closed") {
  return { success: true, alreadyClosed: true };
}

// After: posts comment even if already closed
const wasAlreadyClosed = entity.state === "closed";
await addComment(entity, commentBody);
if (!wasAlreadyClosed) {
  await closeEntity(entity);
}
return { success: true, alreadyClosed: wasAlreadyClosed };
Original prompt

Update the close-issue safe-output type as follows:

  1. Prompt text

    • Explicitly state that a comment can be added when closing an issue.
    • Recommend that a comment should always be added when closing an issue.
  2. Behavior for already-closed issues

    • If the issue is already closed, still post a comment explaining the action or context.

Apply the same updates to:

  • close-pull-request
  • close-discussion

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Changeset

  • Type: patch
  • Description: Ensure closing safe-output handlers still add comments even when the entity is already closed

Generated by Changeset Generator

Copilot AI and others added 2 commits February 13, 2026 18:55
…ready-closed entities

- Updated descriptions in safe_outputs_tools.json for close_issue, close_pull_request, and close_discussion
- Modified handlers to still post comments if entity is already closed
- Updated close_entity_helpers.cjs to support commenting on already-closed entities
- Updated test to verify new behavior

Co-authored-by: pelikhan <[email protected]>
Copilot AI changed the title [WIP] Update close-issue safe-output type Update close safe-output types to recommend comments and handle already-closed entities Feb 13, 2026
Copilot AI requested a review from pelikhan February 13, 2026 19:03
@pelikhan pelikhan marked this pull request as ready for review February 13, 2026 19:14
Copilot AI review requested due to automatic review settings February 13, 2026 19:14
@github-actions
Copy link
Contributor

🧪 Smoke Project is now testing project operations...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

🧪 Smoke Temporary ID is now testing temporary ID functionality...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Feb 13, 2026

Changeset Generator completed successfully!

@github-actions
Copy link
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request updates the close safe-output types (close_issue, close_pull_request, close_discussion) to explicitly recommend adding closing comments in their tool descriptions and to handle already-closed entities by still posting comments to them while skipping redundant close API calls. The changes ensure agents provide context when closing GitHub entities and gracefully handle cases where entities are already in the desired state.

Changes:

  • Updated tool descriptions to recommend adding comments and document behavior for already-closed entities
  • Modified handlers to post comments even when entities are already closed, returning an alreadyClosed flag
  • Added test coverage for the already-closed scenario in close_issue.test.cjs

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/workflow/js/safe_outputs_tools.json Updated descriptions for close_discussion, close_issue, and close_pull_request to recommend comments and document already-closed behavior
actions/setup/js/close_pull_request.cjs Modified to post comments to already-closed PRs, skip redundant close call, return alreadyClosed flag
actions/setup/js/close_issue.cjs Modified to post comments to already-closed issues, skip redundant close call, return alreadyClosed flag
actions/setup/js/close_discussion.cjs Added closed field to GraphQL query, modified to post comments to already-closed discussions, return alreadyClosed flag
actions/setup/js/close_entity_helpers.cjs Updated shared logic to post comments to already-closed entities instead of skipping them
actions/setup/js/close_issue.test.cjs Added test verifying comments are posted to already-closed issues and alreadyClosed flag is returned
docs/src/content/docs/reference/frontmatter-full.md Changed temporary ID example length (appears unrelated to PR purpose and inconsistent with validation pattern)
.github/workflows/*.lock.yml Propagated updated tool descriptions to workflow lock files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# (PAT) or GitHub App token with Projects permissions (default GITHUB_TOKEN cannot
# be used). Agent output includes: project (full URL or temporary project ID like
# aw_XXXXXXXX or #aw_XXXXXXXX from create_project), content_type
# aw_XXXXXXXXXXXX or #aw_XXXXXXXXXXXX from create_project), content_type
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

This change appears unrelated to the PR's stated purpose of updating close safe-output types. Additionally, according to stored codebase memories and the temporary ID validation pattern defined in the codebase (^aw_[A-Za-z0-9]{3,8}$), temporary IDs should be 3-8 alphanumeric characters after the "aw_" prefix. The change from "aw_XXXXXXXX" (8 X's, within the valid range) to "aw_XXXXXXXXXXXX" (12 X's, exceeding the maximum of 8) creates an inconsistency with the actual validation pattern. Either the documentation should use examples within the 3-8 character range, or if longer IDs are now supported, the validation pattern needs to be updated as well.

Copilot uses AI. Check for mistakes.
Comment on lines 155 to 218
@@ -195,23 +191,31 @@ async function main(config = {}) {
}
}

// Close the PR
try {
const closedPR = await closePullRequest(github, owner, repo, prNumber);
core.info(`✓ Closed PR #${prNumber}: ${closedPR.title}`);
return {
success: true,
pull_request_number: closedPR.number,
pull_request_url: closedPR.html_url,
};
} catch (error) {
const errorMsg = getErrorMessage(error);
core.warning(`Failed to close PR #${prNumber}: ${errorMsg}`);
return {
success: false,
error: `Failed to close PR #${prNumber}: ${errorMsg}`,
};
// Close the PR if not already closed
let closedPR;
if (wasAlreadyClosed) {
core.info(`PR #${prNumber} was already closed, comment added`);
closedPR = pr;
} else {
try {
closedPR = await closePullRequest(github, owner, repo, prNumber);
core.info(`✓ Closed PR #${prNumber}: ${closedPR.title}`);
} catch (error) {
const errorMsg = getErrorMessage(error);
core.warning(`Failed to close PR #${prNumber}: ${errorMsg}`);
return {
success: false,
error: `Failed to close PR #${prNumber}: ${errorMsg}`,
};
}
}

return {
success: true,
pull_request_number: closedPR.number,
pull_request_url: closedPR.html_url,
alreadyClosed: wasAlreadyClosed,
};
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The new behavior for handling already-closed pull requests (posting comments and returning the alreadyClosed flag) lacks test coverage. While close_issue.test.cjs has been updated with a test for this scenario (lines 205-248), there are no corresponding tests for close_pull_request. Consider adding a test similar to the one in close_issue.test.cjs that verifies: 1) comments are still posted to already-closed PRs, 2) the alreadyClosed flag is returned correctly, 3) the close API is not called when the PR is already closed.

Copilot uses AI. Check for mistakes.
Comment on lines 241 to 271
@@ -243,17 +252,22 @@ async function main(config = {}) {
commentUrl = comment.url;
}

// Close the discussion
const reason = item.reason || undefined;
core.info(`Closing discussion #${discussionNumber} with reason: ${reason || "none"}`);
const closedDiscussion = await closeDiscussion(github, discussion.id, reason);
core.info(`Closed discussion #${discussionNumber}: ${closedDiscussion.url}`);
// Close the discussion if not already closed
if (wasAlreadyClosed) {
core.info(`Discussion #${discussionNumber} was already closed, comment added`);
} else {
const reason = item.reason || undefined;
core.info(`Closing discussion #${discussionNumber} with reason: ${reason || "none"}`);
const closedDiscussion = await closeDiscussion(github, discussion.id, reason);
core.info(`Closed discussion #${discussionNumber}: ${closedDiscussion.url}`);
}

return {
success: true,
number: discussionNumber,
url: discussion.url,
commentUrl: commentUrl,
alreadyClosed: wasAlreadyClosed,
};
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The new behavior for handling already-closed discussions (posting comments and returning the alreadyClosed flag) lacks test coverage. While close_issue.test.cjs has been updated with a test for this scenario, there are no corresponding tests for close_discussion. Consider adding a test that verifies: 1) comments are still posted to already-closed discussions, 2) the alreadyClosed flag is returned correctly, 3) the close API is not called when the discussion is already closed.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.52.0
jq 1.7
yq 4.52.2
curl 8.x
gh 2.86.0
node 20.20.0
python3 3.12.3
go 1.24.13
java 21.x
dotnet 10.0.102

Result: 12/12 tools available ✅

All required development tools are present and functional in the agent container environment.

AI generated by Agent Container Smoke Test

@github-actions
Copy link
Contributor

Smoke Project completed successfully. All project operations validated.

@github-actions
Copy link
Contributor

Smoke Temporary ID completed successfully. Temporary ID validation passed.

@github-actions
Copy link
Contributor

Smoke test results:
PRs: "Relax temporary ID validation from aw_{4,8} to aw_{3,8}" (#15482); "Skip permission validation when tools.github auto-added" (#15480)
GitHub MCP fetch merged PRs: ✅
Serena activate+find_symbol: ✅
Playwright GitHub title: ✅
File write+cat: ✅
Build make build: ✅
Overall: PASS

AI generated by Smoke Codex

@github-actions github-actions bot removed the smoke label Feb 13, 2026
@github-actions
Copy link
Contributor

🤖✨ Beep boop! The Copilot smoke test agent stopped by to say hello and spread some automated testing joy!

We're out here verifying workflows, checking tools, and making sure everything works smoothly. Kind of like a digital janitor, but with more JavaScript and fewer mops! 🧹→💻

Powered by run §21999636372

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

Smoke Test Results: PASS ✅

PRs Tested: #15478, #15482

Test Result
GitHub MCP
Safe Inputs GH CLI
Serena MCP ⏭️
Playwright
File Writing
Bash Tool
Discussion
Build gh-aw
Dispatch
PR Review

Status: PASS

cc @pelikhan @Copilot

AI generated by Smoke Copilot

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Changes look good - improved close handlers to post comments even when entities are already closed, enhancing transparency

AI generated by Smoke Copilot for #15489

{
"name": "close_discussion",
"description": "Close a GitHub discussion with a resolution comment and optional reason. Use this to mark discussions as resolved, answered, or no longer needed. The closing comment should explain why the discussion is being closed.",
"description": "Close a GitHub discussion with a resolution comment and optional reason. You can and should always add a comment when closing a discussion to explain the action or provide context. Use this to mark discussions as resolved, answered, or no longer needed. The closing comment should explain why the discussion is being closed. If the discussion is already closed, a comment will still be posted.",
Copy link
Contributor

Choose a reason for hiding this comment

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

✅ Good addition - explicitly recommending comments when closing

const wasAlreadyClosed = discussion.closed;
if (wasAlreadyClosed) {
core.info(`Discussion #${discussionNumber} is already closed, but will still add comment`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

✅ Excellent pattern - posting comments to already-closed entities improves transparency

@github-actions
Copy link
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@pelikhan pelikhan merged commit 633c2ca into main Feb 13, 2026
1 check passed
@pelikhan pelikhan deleted the copilot/update-close-issue-output branch February 13, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants