Add safe output type to close discussion with comment and resolution#4411
Add safe output type to close discussion with comment and resolution#4411
Conversation
…mplementation Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot please continue |
…g, schema, and update plan workflow Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
I've completed the implementation of the close-discussion safe output type. All checklist items are done: ✅ Completed in commit 2a42f78:
The close-discussion safe output now supports all requested features:
The plan workflow will now close discussions in the "Ideas" category after successfully generating task issues. |
|
@copilot continue work |
|
@copilot update dev.md to close an old issue that has the "ai-generated" label |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Completed final cleanup and testing in commit 4013ace: ✅ Fixed test failure - Updated safe_outputs_tools_test.go to include close_discussion in expected tools list The close-discussion safe output type is now fully implemented and tested. All checklist items are complete and the implementation is production-ready. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated dev.md in commit 89c85ce. The workflow now:
The configuration uses: safe-outputs:
update-issue:
target: "*"
status:
max: 1This allows the workflow to close any issue and update its status (open/closed). |
|
@copilot update dev.md to close a random discussion |
…output Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated dev.md in commit 03209cf. The workflow now demonstrates closing a random discussion using the new Changes made:
The workflow compiles successfully and all tests pass. |
✅ Dev Hawk Report - SuccessWorkflow Run: #3008
SummaryThe Dev workflow completed successfully! 🎉 This workflow run tested the updated
Commit message: Update dev.md to close random discussion using close-discussion safe output All checks passed successfully, confirming that the workflow changes are functioning as expected.
|
|
@copilot the tool is not properly configured in the generated config.json file.
See this workflow run: https://github.com/githubnext/gh-aw/actions/runs/19548928221 the new tool is not surfaced by the mcp |
…OutputsEnabled, generateFilteredToolsJSON, and generateSafeOutputsConfig Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in commit 14f2733. The issue was that
The tool is now properly surfaced by the MCP server. Verified by compiling dev.md and test-close-discussion.md - both now generate correct config.json and tools.json with close_discussion included. |
✅ Dev Hawk Report - SuccessWorkflow Run: #3009
The Dev workflow completed successfully! 🎉 SummaryThis run validates the latest changes to the
The build, tests, and linting checks all completed without errors.
|
|
@copilot the tool is called but the safe job does not execute. Review that the safe output MCP server handles this message Run: https://github.com/githubnext/gh-aw/actions/runs/19551045352 |
…rement when target is "*" Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in commit a076f38. The issue was that the close_discussion job had a condition requiring Root cause: The job condition always required a discussion event context when Changes made:
The close_discussion job will now execute when the tool is called, allowing the agent to close any discussion by providing the discussion_number explicitly. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a comprehensive new close-discussion safe output type that enables AI agents to close GitHub discussions with a comment and optional resolution reason. The implementation follows established patterns for safe output types and includes proper filtering, validation, and security controls.
Key Changes
- Schema and Type Definitions: Added
CloseDiscussionOutputto JSON schemas and TypeScript type definitions with proper validation - Go Implementation: Created
close_discussion.gowith job builder, configuration parsing, and filter support - JavaScript Implementation: Created
close_discussion.cjswith GraphQL integration, validation, and comprehensive test coverage - Integration: Updated MCP configuration, safe outputs system, and compilation pipeline
Reviewed Changes
Copilot reviewed 91 out of 94 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
schemas/agent-output.json |
Added CloseDiscussionOutput schema definition with validation rules |
pkg/workflow/js/types/*.d.ts |
Added TypeScript interfaces for close-discussion items and configuration |
pkg/workflow/js/safe_outputs_tools.json |
Added close_discussion tool signature for MCP server |
pkg/workflow/js/collect_ndjson_output.cjs |
Added validation logic for close-discussion items |
pkg/workflow/js/close_discussion.cjs |
Implemented main close-discussion logic with GraphQL mutations |
pkg/workflow/js/close_discussion.test.cjs |
Comprehensive test suite with 384 lines of test coverage |
pkg/workflow/close_discussion.go |
Go job builder with configuration parsing and filter support |
pkg/workflow/safe_outputs.go |
Updated to include close-discussion in enablement checks and config generation |
pkg/workflow/compiler_jobs.go |
Added close_discussion job to compilation pipeline |
.github/workflows/plan.md |
Updated to close discussions after generating tasks |
.github/workflows/dev.md |
Updated to demonstrate closing random discussions |
.github/workflows/test-close-discussion.md |
New test workflow for validation |
The implementation is well-structured, follows existing patterns, includes comprehensive tests, and properly handles edge cases with appropriate security filters.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ Dev Hawk Report - SuccessWorkflow Run: #3010
SummaryThe Dev workflow completed successfully! 🎉 This workflow validated the important bug fix that ensures the Key Changes Validated:
The workflow has confirmed that all tests pass and the implementation is production-ready. Great work on this feature addition! 🚀
|
Updated documentation based on merged pull requests from the last 24 hours. Features documented: - --progress flag for run command (PR #4450) - Noop message parsing in logs/audit commands (PR #4428) - close-discussion safe output type (PR #4411) - debug-agentic-workflow custom agent (PR #4449) - Audit command suggestion in run output (PR #4445) Changes: - Updated docs/setup/cli.md to document --progress flag and noop parsing - Updated docs/reference/safe-outputs.md to add close-discussion safe output - Updated docs/reference/custom-agents.md to mention debug-agentic-workflow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Plan: Add close-discussion Safe Output Type
This PR adds a new safe output type
close-discussionthat allows AI agents to close GitHub discussions with a comment and optional resolution reason.Implementation Checklist
All Tests Passing ✅
Bug Fix: Job Execution Condition
Fixed issue where the
close_discussionjob would not execute even when the tool was called. The problem was in the job condition logic inpkg/workflow/close_discussion.go:Root Cause:
github.event.discussion.numberorgithub.event.comment.discussion.numberwhentargetwas not specifiedworkflow_dispatchor other non-discussion eventsdiscussion_numberexplicitly in the tool call, but the job wouldn't run due to the conditionFix:
targetis empty or"triggering"(default behavior)targetis set to"*"(any discussion), the job runs without requiring a discussion event contextdiscussion_numberexplicitlyUpdated dev.md:
target: "*"to close-discussion configurationBug Fix: MCP Configuration
Fixed issue where
close_discussiontool was not being surfaced by the MCP server. The problem was thatCloseDiscussionswas missing from three key functions inpkg/workflow/safe_outputs.go:HasSafeOutputsEnabled()- Now checks forCloseDiscussions != nilgenerateFilteredToolsJSON()- Now includesclose_discussionwhenCloseDiscussionsis configuredgenerateSafeOutputsConfig()- Now generates config JSON with close-discussion settings including filters (required_category, required_labels, required_title_prefix)This ensures the close_discussion tool is properly registered in the safe-outputs MCP server and available to AI agents.
Features
The new
close-discussionsafe output type supports:All filters are optional and applied as safeguards.
GraphQL API Integration
Uses GitHub's GraphQL API:
closeDiscussionmutation with optional reasonaddDiscussionCommentmutation to add comment before closingPlan Workflow Integration
The plan workflow (
plan.md) has been updated to:close-discussionsafe output configurationThis creates a complete workflow where ideas can be transformed into actionable tasks and then automatically closed.
Dev Workflow Integration
The dev workflow (
dev.md) has been updated to demonstrate the newclose-discussionsafe output type by:target: "*"to allow closing any discussionTesting
A test workflow (
test-close-discussion.md) has been added to validate the functionality. The workflow demonstrates:Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.