Update close safe-output types to recommend comments and handle already-closed entities#15489
Update close safe-output types to recommend comments and handle already-closed entities#15489
Conversation
…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]>
….json changes Co-authored-by: pelikhan <[email protected]>
|
🧪 Smoke Project is now testing project operations... |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
🧪 Smoke Temporary ID is now testing temporary ID functionality... |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
✅ Changeset Generator completed successfully! |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
There was a problem hiding this comment.
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
alreadyClosedflag - 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 |
There was a problem hiding this comment.
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.
| @@ -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, | |||
| }; | |||
There was a problem hiding this comment.
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.
| @@ -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, | |||
| }; | |||
There was a problem hiding this comment.
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.
Agent Container Tool Check
Result: 12/12 tools available ✅ All required development tools are present and functional in the agent container environment.
|
|
✅ Smoke Project completed successfully. All project operations validated. |
|
✅ Smoke Temporary ID completed successfully. Temporary ID validation passed. |
|
Smoke test results:
|
|
🤖✨ 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! 🧹→💻
|
Smoke Test Results: PASS ✅
Status: PASS cc @pelikhan
|
There was a problem hiding this comment.
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.", |
There was a problem hiding this comment.
✅ 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`); | ||
| } |
There was a problem hiding this comment.
✅ Excellent pattern - posting comments to already-closed entities improves transparency
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
Modified
close_issue,close_pull_request, andclose_discussionsafe-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)Handler behavior
close_issue.cjs,close_pull_request.cjs: Now post comments to already-closed entities, returnalreadyClosed: trueflag, skip redundant close API callclose_discussion.cjs: Addedclosedfield to GraphQL query, posts comments to already-closed discussionsclose_entity_helpers.cjs: Updated shared logic to comment on already-closed entities instead of skippingExample behavior
Original prompt
💡 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