Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

Implements minimize-comment safe output allowing AI agents to hide comments on issues/PRs/discussions via GraphQL's minimizeComment mutation.

Implementation

Schema & Types

  • schemas/agent-output.json: Added MinimizeCommentOutput with string comment_id (GraphQL node IDs only)
  • pkg/parser/schemas/main_workflow_schema.json: Added minimize-comment configuration (max, target-repo, github-token)
  • pkg/workflow/js/types/safe-outputs.d.ts: Added MinimizeCommentItem interface

JavaScript Implementation

  • pkg/workflow/js/minimize_comment.cjs: GraphQL mutation with SPAM classifier, staged mode support
  • pkg/workflow/js/minimize_comment.test.cjs: 8 unit tests covering all scenarios
  • pkg/workflow/js/safe_outputs_tools.json: Tool signature emphasizing GraphQL node ID requirement

Go Integration

  • pkg/workflow/minimize_comment.go: Job builder with MinimizeCommentConfig, uses shared config types and buildSafeOutputJob helper
  • pkg/workflow/compiler_types.go: Added MinimizeComment to SafeOutputsConfig
  • pkg/workflow/compiler_jobs.go: Job builder integration with detection job dependency
  • pkg/workflow/safe_outputs.go: Tool filtering and enablement
  • pkg/workflow/scripts.go: Script registration

Test Workflows

  • pkg/cli/workflows/test-copilot-minimize-comment.md: Test workflow for Copilot engine
  • pkg/cli/workflows/test-claude-minimize-comment.md: Test workflow for Claude engine
  • pkg/cli/workflows/test-codex-minimize-comment.md: Test workflow for Codex engine
  • .github/workflows/smoke-codex.md: Added minimize-comment to smoke test workflow

Permissions

Uses NewPermissionsContentsReadIssuesWritePRWriteDiscussionsWrite() matching the full scope (issues, PRs, discussions).

Usage

safe-outputs:
  minimize-comment:
    max: 5
    target-repo: owner/repo  # optional
// Agent output (JSONL)
{
  "type": "minimize_comment",
  "comment_id": "IC_kwDOABCD123456"  // GraphQL node ID (string only)
}

Key Design Decisions

String-only comment_id: GraphQL node IDs are always strings (e.g., IC_kwDOABCD123456). Numeric REST API comment IDs cannot be converted to GraphQL node IDs, so schema explicitly rejects numbers to prevent confusion.

SPAM classifier: Uses SPAM classifier for the minimizeComment mutation, appropriate for moderation use cases.

[!WARNING]

Custom agent used: create-safe-output-type
Adding a New Safe Output Type to GitHub Agentic Workflows

Original prompt

Create "minimize-comment" safe output type that allows the agent to minimize a comment.

  • implemented with graphql

/**
 * Hide (minimize) a comment using the GraphQL API.
 */
export async function minimizeComment(
  octokit: ReturnType<typeof github.getOctokit>,
  nodeId: string
): Promise<void> {
  const query = /* GraphQL */ `
    mutation ($nodeId: ID!) {
      minimizeComment(input: { subjectId: $nodeId, classifier: SPAM }) {
        minimizedComment {
          isMinimized
        }
      }
    }
  `

  await octokit.graphql(query, { nodeId })
}

Custom agent used: create-safe-output-type
Adding a New Safe Output Type to GitHub Agentic Workflows


💡 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.

Copilot AI and others added 5 commits December 8, 2025 22:29
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Updated JSON schema with MinimizeCommentOutput definition
- Added TypeScript types for MinimizeCommentItem
- Updated safe_outputs_tools.json with minimize_comment tool signature
- Created minimize_comment.cjs JavaScript implementation with GraphQL mutation
- Created minimize_comment.test.cjs with comprehensive tests
- Added MinimizeCommentConfig to Go types
- Created minimize_comment.go with job builder
- Updated safe_outputs.go to include minimize_comment in enabledTools and HasSafeOutputsEnabled
- Updated compiler_jobs.go to build minimize_comment job
- Integrated minimize_comment parser in extractSafeOutputsConfig

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Added minimize_comment to expectedTools list in safe_outputs_tools_test.go
- Fixed script registration in scripts.go
- All tests now passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Updated main_workflow_schema.json with minimize-comment configuration
- Created test workflows for copilot, claude, and codex engines
- All tests passing
- Workflows compile successfully

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Remove unused getRepositoryUrl import from minimize_comment.cjs
- Add support for numeric comment_id values (convert to string for GraphQL)
- Improve error messages to be more descriptive
- All tests still passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan
Copy link
Contributor

pelikhan commented Dec 8, 2025

@copilot

  • add test workflow in pkg/cli/workflows
  • add minimize comment safe output to smoke-codex
  • make sure the new javacsript files are register in the ScriptRegistry

Copilot AI and others added 2 commits December 8, 2025 22:59
- Changed from NewPermissionsContentsReadIssuesWrite() to
  NewPermissionsContentsReadIssuesWritePRWriteDiscussionsWrite()
- Matches broader scope of minimize_comment (works on issues, PRs, and discussions)
- Aligns with add_comment permissions pattern

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Changed comment_id from (number|string) to string only in all schemas
- GraphQL node IDs are always strings (e.g., 'IC_kwDOABCD123456')
- Numeric REST API comment IDs cannot be converted to GraphQL node IDs
- Updated error message to clarify GraphQL node ID requirement
- Updated tool description to emphasize GraphQL node ID vs REST comment ID
- All tests still passing

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add minimize comment functionality with GraphQL Add minimize-comment safe output type for GraphQL-based comment moderation Dec 8, 2025
Copilot AI requested a review from pelikhan December 8, 2025 23:08
- Added minimize-comment safe output to smoke-codex.md
- Recompiled smoke-codex.lock.yml with minimize_comment job
- All test workflows already created in pkg/cli/workflows
- ScriptRegistry already has minimize_comment registered

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 8, 2025

@copilot

  • add test workflow in pkg/cli/workflows
  • add minimize comment safe output to smoke-codex
    ...

Done in commit decede3:

  • ✅ Test workflows already in pkg/cli/workflows (test-copilot-minimize-comment.md, test-claude-minimize-comment.md, test-codex-minimize-comment.md)
  • ✅ Added minimize-comment to smoke-codex.md safe-outputs
  • ✅ ScriptRegistry already registered minimize_comment (scripts.go line 55, 153)

@pelikhan pelikhan marked this pull request as ready for review December 8, 2025 23:20
@pelikhan pelikhan merged commit eb9c055 into main Dec 8, 2025
22 checks passed
@pelikhan pelikhan deleted the copilot/add-minimize-comment-function branch December 8, 2025 23:20
github-actions bot added a commit that referenced this pull request Dec 9, 2025
Added documentation for two new user-facing features merged in the last 24 hours:

1. Workflow labels field (PR #5912)
   - Added `labels` field documentation to frontmatter.md
   - Documented `--label` flag for status command in cli.md
   - Labels enable workflow categorization and filtering

2. Minimize-comment safe output (PR #5911)
   - Added `minimize-comment` to safe-outputs.md table
   - Created detailed section with usage, requirements, and examples
   - Documents GraphQL node ID requirement and SPAM classification

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
github-actions bot added a commit that referenced this pull request Dec 9, 2025
Add two new glossary terms from recent features:
- Labels: workflow categorization and filtering
- Minimize Comment: safe output for comment moderation

Related: #5912, #5911
@github-actions github-actions bot mentioned this pull request Dec 9, 2025
2 tasks
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.

2 participants