Repository navigation
Add pull request auto-merge tool - #3986
Merged
Merged
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The new write tool authorizes future repository merges, extending effects beyond the current call and introducing authorization, branch-protection, and later-head-change interactions that warrant human review.
No open issues 🎉
What changed in this PR
Adds enable_pull_request_auto_merge behind the pull_requests_granular feature flag, letting agents schedule a merge once GitHub’s requirements are met rather than merge immediately.
Changes:
- Implements the GraphQL mutation using the existing merge tool’s input schema.
- Adds coverage for argument mapping, errors, feature gating, protocol output, and tool snapshots.
- Updates the pull-request-authoring skill and generated feature-flag documentation.
| File | Description |
|---|---|
pkg/skills/catalog/tools.go |
Adds auto-merge to the authoring skill’s optional tools. |
pkg/skills/catalog/skills/pull-request-authoring/SKILL.md |
Explains auto-merge behavior and required user confirmation. |
pkg/github/typed_granular_pull_request_outputs_test.go |
Covers typed protocol output and error handling. |
pkg/github/tools.go |
Registers the new tool. |
pkg/github/pullrequests.go |
Extracts the shared merge input schema. |
pkg/github/pull_request_auto_merge.go |
Implements validation, GraphQL calls, and feature gating. |
pkg/github/pull_request_auto_merge_test.go |
Tests defaults, options, failures, and feature gating. |
pkg/github/granular_tools_test.go |
Updates expected granular tool availability. |
pkg/github/__toolsnaps__/enable_pull_request_auto_merge.snap |
Records the new tool’s schema and metadata. |
docs/feature-flags.md |
Documents the tool’s inputs and required scope. |
Review effort: Balanced (adaptive)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
timrogers
commented
Dec 1, 2026
Use consistent snake_case inputs for the new tool, title-case its metadata, and clarify auto-merge defaults and repository requirements without changing the existing merge tool API. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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 a tool to enable auto-merge behind the
pull_requests_granularfeature flag and expose its state when reading a pull request.Why
Agents currently have a tool to merge immediately but cannot schedule a merge after GitHub's requirements are met. No linked issue.
What changed
enable_pull_request_auto_merge, using GitHub's GraphQL mutation with the same merge options asmerge_pull_requestand consistently snake_case inputs.auto_mergestate, merge method, and enabler topull_request_read'sgetresponse without changing list responses.MCP impact
The new write tool is available only when
pull_requests_granularis enabled. Its inputs use snake_case, includingpull_numberandexpected_head_sha; existing merge-tool inputs are unchanged. GitHub defaults to themergemethod if none is supplied.pull_request_readreturnsauto_merge: nullwhen disabled or an object when enabled.Prompts tested (tool changes only)
pull_request_readresults across supported protocol versions.tools/callrequests against GitHub from a locally built server at PR head83d4823, withpull_requests_granularenabled:merge_method: squashand the currentexpectedHeadShasucceeded. GitHub confirmed auto-merge was enabled; it was then disabled and confirmed off.expectedHeadShawas rejected and left auto-merge disabled.MERGE.Security / limits
The tool requires the
reposcope; GitHub enforces repository permissions and auto-merge eligibility. The optionalexpected_head_shaguards against enabling auto-merge on a changed head. As withmerge_pull_request, the MCP client decides when to present confirmations; the handler does not introduce a separate confirmation field.Tool renaming
deprecated_tool_aliases.goNo existing tools were renamed.
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.Also passed:
UPDATE_TOOLSNAPS=true go test ./...andscript/generate-docs.go build -o /root/.copilot/session-state/bd4800d3bbe24f9d8fc6e277cef7753b/files/github-mcp-auto-merge ./cmd/github-mcp-server— passed for the live MCP tests above.Docs
Regenerated
docs/feature-flags.mdwith the new tool.Skills
Updated the pull-request-authoring skill and its tool catalog.