Skip to content

[Github Agent] Add merge conflict resolution action - #2975

Draft
George Ng (GeorgeNgMsft) wants to merge 9 commits into
mainfrom
georgengmsft-merge-conflict-action
Draft

[Github Agent] Add merge conflict resolution action#2975
George Ng (GeorgeNgMsft) wants to merge 9 commits into
mainfrom
georgengmsft-merge-conflict-action

Conversation

@GeorgeNgMsft

@GeorgeNgMsft George Ng (GeorgeNgMsft) commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR lets the GitHub agent merge another branch into the current local branch and resolve conflicts without requiring a connected editor. Ask “resolve merge conflicts from main”, or omit the branch to use the remote's default. TypeAgent fetches the source branch and starts the merge. Clean merges are committed directly; when conflicts occur, Reasoning uses native file and terminal tools to resolve and stage them, then a separate completion action verifies the index and creates the merge commit. The action never switches branches or pushes.

The implementation also fixes the tool configuration that previously left Reasoning unable to edit files or run Git, causing repeated failed attempts and timeouts. Completion no longer depends on the model remembering to call a final action or merely claiming success. Both merge actions use the repository authorized by the host request, rather than the agent server's working directory.

The optional targetBranch is the source, not the destination. To merge main into release, first check out release, then ask “resolve merge conflicts from main.” MCP clients can invoke the same action directly.

Highlights

  • Rejects dirty worktrees, detached HEAD, and existing Git operations before starting a merge.
  • Fetches into a unique temporary ref, keeping the selected source pinned until cleanup.
  • Gives Reasoning usable native tools for Claude and GPT tool variants, including terminal output and cancellation tools, without changing the existing permission checks.
  • Queues deterministic completion after Reasoning; unresolved conflicts, unstaged edits, unrelated staged paths, and leftover conflict markers block the commit.
  • Records the actual post-merge staged paths, including edits Git automatically applies through renames. Saved state is bound to HEAD and MERGE_HEAD; missing, invalid, or stale state requires manual inspection and recovery.
  • Propagates request cancellation to Git and prevents subsequent merge or commit operations. Temporary-ref cleanup still runs; an already-started merge is left available for inspection rather than automatically reset or aborted.
  • Centralizes cancellation handling and repository guards, combines Git queries, and reuses regression fixtures to reduce duplication and subprocess overhead.

Validation

  • GitHub CLI agent build and full local suite: 207 tests passed.
  • Dispatcher build and full local suite: 2,002 tests passed, with one existing skipped test.
  • Installed Copilot SDK contract checks: 2 passed, covering initialized Claude and GPT native-tool inventories without sending model prompts.
  • Real-Git regressions cover automatic rename resolution, separate host/request repositories, merge parents, staged conflict markers, and incomplete resolution. Mocked regressions cover cancellation and invalid or stale saved state.
  • Live dispatcher + Reasoning run reproduced this branch's historical conflict in a disposable repository and completed in 43 seconds, producing the correct two-parent merge commit with a clean worktree and leaving the host repository unchanged.
  • Formatting and all four PR gates passed: lint, complexity, circular dependencies, and test debt.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title Add deterministic merge conflict actions [Github Agent] Add action to resolve merge conflicts Sep 4, 2026
Use the existing Reasoning action to resolve conflicted files, then verify and create the merge commit without pushing. Remove the per-action readiness framework added by the earlier implementation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title [Github Agent] Add action to resolve merge conflicts Add merge conflict resolution action Sep 4, 2026
@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title Add merge conflict resolution action [Github Agent]Add merge conflict resolution action Sep 4, 2026
@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title [Github Agent]Add merge conflict resolution action [Github Agent] Add merge conflict resolution action Sep 4, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GeorgeNgMsft
George Ng (GeorgeNgMsft) marked this pull request as draft September 4, 2026 20:13
Use current Copilot built-in tool filters, including model-specific editors and shell lifecycle tools. Cover deterministic merge completion and real Git conflict handling with regression tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fb5bc7a3-4119-4f6d-a71b-f928f2490ffa
Use the host-authorized repository and propagate request cancellation. Bind completion to the actual merge state and staged paths, preserving automatic rename resolutions. Consolidate Git probes and regression fixtures, and add an installed SDK tool contract check.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fb5bc7a3-4119-4f6d-a71b-f928f2490ffa
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.

1 participant