AI-assisted development · Pull request repair

From AI-written code to a mergeable pull request

An AI coding agent opens a pull request to add a discount to an order summary. The checks pass and a reviewer approves it. Before the team merges, another engineer changes the shared price calculation on the main branch. The pull request now has a conflict. An agent resolves it, pushes another commit and reports that the change is ready.

The reviewer returns to a different diff. Which checks cover this version? Did the conflict resolution preserve the new calculation? Does the earlier approval still satisfy the repository's rules? The code exists, but someone still has to establish whether the team can accept it.

GitHub's 28 October release brings Agent Merge into pull requests on GitHub: Copilot can watch for failed Actions workflows, merge conflicts or both, then attempt fixes. That makes the work after opening a PR a useful engineering boundary to examine. A repair loop needs a defined scope, current evidence and a person responsible for the decision it cannot make.

The order-summary example below is an illustrative design. I have not run Agent Merge for this article or measured its repair quality. The proposed policies and acceptance cases describe how I would evaluate a bounded workflow with a team.

Separate repair, review and merging

Agent Merge and auto-merge have different responsibilities. The former works on selected blockers; the latter merges when the repository's requirements are satisfied. Enabling Agent Merge does not enable auto-merge. A team can start with repairs enabled and keep merging manual while it learns what the resulting diffs look like.

Availability also constrains that choice. Current GitHub documentation requires paid Copilot cloud access, permitted organisation policies and the repository's automations policy. It excludes fork-origin and stacked pull requests. Check the actual repository before designing a process around this feature; a conventional engineer-led repair remains a useful baseline.

I would begin with one repository and one allowed blocker category. Agree who reviews the patch, who owns a failed workflow and who can stop the watcher. That makes it possible to evaluate a specific delegation rather than asking an agent to keep changing code until the PR can merge.

Give each repair a narrow contract

For the discount change, the intended behaviour is explicit: apply the agreed discount once, preserve currency and rounding, and show the same total in the summary and checkout. Fixing a compile error must preserve those requirements. Changing a failed assertion to accept a different total needs a separate explanation and review.

I would record the blocker, PR head commit, relevant base revision, diagnostic evidence and permitted repair scope before each attempt. Protect the test expectations and workflow controls that define acceptance. A repair may need a test change when a contract intentionally changes, but that decision belongs with the engineer who owns the contract.

Proposed repair responsibilities
BlockerProposed automatic scopeDecision retained by the team
Deterministic compile or test failurePatch the diagnosed defect while preserving agreed behaviourReview the diff and evidence for the intended result
Merge conflictReconcile changes where their combined meaning is clearResolve changed business rules or ambiguous contracts
Runner outage or unavailable servicePreserve diagnostics and report the dependencyDecide when to rerun; a product-code patch may be irrelevant
Repeated intermittent test failureCollect the failing case and run historyInvestigate flakiness before treating a later green run as a repair

GitHub's documented repair environment uses GitHub Actions and repository customisations. I would make its setup reproducible and limit credentials to what the selected checks need. Instructions can explain the permitted repair; repository permissions and required checks must enforce the boundaries that matter. A sentence asking the agent to leave protections alone is insufficient if its credentials can bypass them.

Bind evidence to the version being accepted

A PR number identifies a conversation whose contents can change. It does not identify a fixed patch. Keep check results, repair summaries and review decisions associated with the commit or diff they actually examined. After a new push, inspect the new revision instead of carrying the old green state into the handover summary.

Suppose the initial PR head is h1 and the repair creates h2. The passing run for h1 remains useful history. It cannot establish the behaviour of h2. Check the commit attached to the new run, and distinguish checks of the branch head from checks of a temporary merge candidate. Those candidates may contain additional base-branch changes.

Checks passed for h1. A repair creates h2, which needs current checks and review under the proposed team policy. The h1 result stays historical.
Proposed review policy: a new repair commit needs current evidence. Configure the repository's review requirements to match that policy; the diagram does not imply that GitHub automatically dismisses every earlier approval.
Checks passed for h1. A repair creates h2, which needs current checks and review under the proposed team policy. The h1 result stays historical.

GitHub provides options to dismiss stale approvals or require approval of the most recent reviewable push. Choose and verify the policy deliberately. For this first rollout, I would require someone other than the patch author to examine the latest repair before merging. Document how bypass permissions affect that promise as well.

A small evidence record is enough: PR, head commit, tested candidate, workflow run, blocker, repair attempt and reviewer decision. If the base changes again, establish whether the relevant integration checks still cover the combination to be merged. Rebuilding that evidence is preferable to describing an old run as current.

Resolve the meaning behind the conflict

In the example, the discount branch expects calculateTotal() to return an integer number of cents. Meanwhile, main changes it to return an object containing an amount in cents and a currency. Both branches may edit the same caller. Removing the conflict markers only establishes that Git can store the combined text.

The useful review follows the value through its consumers. Does the discount operate on the amount exactly once? Is the currency preserved? Does the checkout use the same result as the summary? A resolution that extracts the amount but silently supplies a default currency could compile while changing the product's behaviour.

I would add or retain a focused regression around that contract, then exercise the summary-to-checkout path using the reconciled implementation. If the two changes disagree about rounding or which discounts can combine, stop and ask the responsible engineer to settle the rule. The agent should not invent a business decision to clear the conflict.

That is also why passing checks need interpretation. A suite that only asserts the presence of a formatted price may miss a calculation error. The earlier article on testing AI-built software across feature boundaries explores those application contracts; here the delivery workflow must make a changed contract visible to the next reviewer.

Stop when the next attempt needs a person

A repair loop needs an exit condition before its first failure. For a pilot, I would allow at most two automatic patch attempts for one diagnosed blocker, with a separate time or usage ceiling. These are proposed starting limits, not measured optimal values or a claim about Agent Merge's built-in settings. Check which controls the selected tool actually exposes and how the operator will enforce the rest.

A clear code defect enters a bounded repair and check loop. Infrastructure waits for its owner; an ambiguous rule or an exhausted attempt budget requires an engineer.
Proposed pilot policy, not a built-in Agent Merge state machine. Count retries across new commits for the same unresolved blocker; creating another commit must not reset the budget.
A clear code defect enters a bounded repair and check loop. Infrastructure waits for its owner; an ambiguous rule or an exhausted attempt budget requires an engineer.

Keep the count against the unresolved problem, not just the current commit. Otherwise each patch can create a new commit and appear to start a fresh allowance. A newly classified blocker needs an explicit record too, so a renamed check cannot hide the same repeating failure.

When the limit is reached, hand over the failing run, the current head, attempted diffs, remaining uncertainty and the next decision needed. Name an engineer who can accept that handover and stop further automatic edits. For an infrastructure failure, the useful next action may be waiting for the service owner. For an ambiguous price rule, it is a contract decision.

Verify the path into the target branch

A busy main branch can move while the repaired PR is under review. With strict status checks, the branch must be current with its base; with a configured merge queue, checks run against a candidate containing the latest target branch and changes ahead in the queue. Choose the integration policy that fits the repository's activity and available features.

For GitHub Actions checks required by a merge queue, configure the merge_group trigger as well as the PR trigger. A missing required result is an integration problem to investigate. It should not be solved by quietly removing that requirement so the queue can proceed.

Main, queued changes and the reviewed PR form a merge candidate with its own SHA. Required checks and repository requirements lead to merge or investigation.
A merge queue validates a combined candidate, which has its own identity. Confirm the required results for that candidate and the repository's review requirements before treating the PR as ready. Merging and deployment remain separate milestones.
Main, queued changes and the reviewed PR form a merge candidate with its own SHA. Required checks and repository requirements lead to merge or investigation.

Before enabling a watcher broadly, I would exercise a small acceptance set in a disposable repository with no production credentials. The following are expected observations for that evaluation. They have not been run for this article.

Proposed acceptance cases; not executed results
Acceptance caseExpected evidence
A repair pushes a new commit after the first checks passThe old run remains attached to its tested commit; current checks and required review cover the repair
Both branches change the price contractThe combined implementation preserves amount, currency and rounding, or explicitly waits for an engineer decision
A runner outage or intermittent failure repeatsDiagnostics identify the unresolved cause; retries do not create an unlimited stream of product patches
The same blocker exceeds the pilot budgetAutomatic edits stop and a named engineer receives the current diff, runs and uncertainty
Main changes while the PR waits to mergeThe configured integration path validates the applicable current candidate; queue checks report when required

Track waiting time alongside active reviewer effort, repair attempts and changes reviewers had to undo. Compare similar blocker categories with the existing manual workflow. A shorter interval to merge is a weak result if the team spends more time understanding patches or repairs defects after release. Any claimed improvement needs observations from that rollout.

Give the workflow an engineering owner

My work on Slivo includes shaping the voice shopping workflow, coordinating AI-assisted development across the widget, integrations and SaaS backend, and checking the journey from recommendation to order. It is a working demonstration product. That experience is relevant to reviewing generated changes against a complete outcome; it is not evidence of an Agent Merge deployment.

For a team adopting automated PR repair, I would own the initial scope, repository-rule review, acceptance cases and investigation of failed attempts with the engineers responsible for the application. The handover should leave a reproducible check environment, clear repair boundaries, current review evidence and an operating route for work the agent cannot finish.

If your coding agents produce patches faster than the team can accept them, tell me about your team and the engineering role. Bring one PR that keeps getting stuck, the checks blocking it and who currently has to intervene. That gives us a concrete starting point for improving the path from generated code to a change your team can support.

Available for project work

What do you need built?

Tell me what you want to achieve, your current tools and the result you expect. For an existing integration, include an example of what goes wrong.

Send your project brief

Let’s work together

Tell me about your project.

What would you like to build or improve? Share a few details and I’ll get back to you by email.

One PDF, DOCX, TXT, PNG or JPG file, up to 10 MB.

Up to two requests per hour.

Your details, IP address and attachment are sent to me to respond to this request and prevent spam. Your country and region are estimated from your IP address. Please leave out passwords and sensitive personal information. IP Geolocation by DB-IP.

Delivered directly to my inbox.