Repository navigation
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
| if output.Enabled { | ||
| target = &output.Enrollment | ||
| } | ||
| resp, err := client.Do(request, target) |
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The new enrollment tool grants and revokes persistent permissions for asynchronous repository writes, requiring human review of its authorization lifecycle, ownership, and eligibility boundaries.
No open issues 🎉
What changed in this PR
Adds a granular tool for managing Agent Merge enrollment, allowing clients to delegate CI fixes and merge conflict resolution to Copilot within pull request workflows.
Changes:
- Supports enabling or replacing allowed actions, and disabling enrollment with an empty array.
- Registers the tool behind the granular pull request feature flag.
- Adds validation, API-response and feature-gate tests, schema coverage, documentation, and skill guidance.
| File | Description |
|---|---|
pkg/skills/catalog/tools.go |
Adds the tool to the pull-request-authoring skill’s optional tools. |
pkg/skills/catalog/skills/pull-request-authoring/SKILL.md |
Documents enrollment, authorization, and eligibility requirements. |
pkg/github/tools.go |
Registers the new tool. |
pkg/github/pull_request_agent_merge.go |
Implements enrollment updates, validation, and API error handling. |
pkg/github/pull_request_agent_merge_test.go |
Tests enrollment operations, validation, API responses, and feature gating. |
pkg/github/granular_tools_test.go |
Includes the tool in snapshot and toolset checks. |
pkg/github/__toolsnaps__/update_pull_request_agent_merge_enrollment.snap |
Records the tool’s schema and annotations. |
docs/feature-flags.md |
Documents the feature-gated tool and its parameters. |
Review effort: Balanced (adaptive)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
| Required: []string{"owner", "repo", "pullNumber", "allowedActions"}, | ||
| }, | ||
| }, | ||
| scopes.RequireAll(scopes.Repo), |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
| if err != nil { | ||
| return utils.NewToolResultErrorFromErr("failed to marshal Agent Merge enrollment", err), nil, nil | ||
| } | ||
| return utils.NewToolResultText(string(text)), output, nil |
|
|
||
| // GranularUpdatePullRequestAgentMergeEnrollment creates a tool to enable, update, or disable Agent Merge. | ||
| func GranularUpdatePullRequestAgentMergeEnrollment(t translations.TranslationHelperFunc) inventory.ServerTool { | ||
| tool := NewTool[UpdatePullRequestAgentMergeEnrollmentInput, *UpdatePullRequestAgentMergeEnrollmentOutput]( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add granular tools to read, enable, update, and disable Agent Merge for a pull request.
Why
Clients need to delegate CI fixes and merge conflict resolution to Copilot from the pull request workflow. No linked issue.
What changed
update_pull_request_agent_merge_enrollmentusing the Agent Merge REST API.get_pull_request_agent_merge_enrollmentto read enabled enrollment and allowed actions.MCP impact
The read tool takes repository and PR coordinates. The write tool also takes an action array: an empty array disables enrollment; nonempty arrays enable or replace the allowed actions. A read 404 is ambiguous and is returned as an error rather than definitively reporting disabled enrollment.
Prompts tested (tool changes only)
Security / limits
Both tools use the
repoOAuth challenge and the API enforces repository write access. Enabling permits asynchronous Copilot actions; it does not merge the PR immediately. The read result is labeled private when IFC labels are enabled because enrollment requires write access even on public repositories.Tool renaming
deprecated_tool_aliases.goThis adds new tools without renaming existing tools.
Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.
Lint & tests
./script/lint— passed../script/test— passed.UPDATE_TOOLSNAPS=true go test ./...— passed.go test ./pkg/github -run 'TestUpdatePullRequestAgentMergeEnrollment|TestGranularToolSnaps|TestPullRequestsGranularToolset' -count=1— passed.go test ./pkg/skills/catalog -run TestCatalogToolRequirementsAreRegistered -count=1— passed.Live end-to-end testing on this PR using the locally built server (
f4d20848), stdio MCP calls, and the session network/authentication setup — passed:tools/listwith--features=pull_requests_granular --toolsets=pull_requests.["fix_ci"], disabled it with[], and re-enabled it with["fix_ci","resolve_merge_conflicts"].2025-11-25.The original enrollment includes
respond_to_copilot_code_reviews, an additional API action the tool's input does not yet accept. Restoring that three-action selection required a direct REST call; the output schema can represent the additional action.This validates enrollment management, not Copilot execution of CI fixes/conflict resolution or eventual merging.
Live read-tool testing: built the local server with
go build -o /root/.copilot/session-state/e21bcb87be2a497fb56b6ded36fd0cb1/files/agent-merge-read-server ./cmd/github-mcp-serverand calledget_pull_request_agent_merge_enrollmentover stdio with--features=pull_requests_granular --toolsets=pull_requestsusinggh auth token. The call for this PR returned its enabled enrollment and all three existing actions; a call for a nonexistent PR returned a 404 tool error explaining its ambiguity. Both passed without modifying enrollment.Docs
script/generate-docspassed and updated the feature-flag documentation.Skills
Updated the pull-request-authoring skill to describe enrollment and the authorization boundary.